Skip to content

Commit

Permalink
Ericbrehault/sc 9214/sync labels are missing in links (#25)
Browse files Browse the repository at this point in the history
* set labels when pushing links

* use same version for sync agent and server [sc-9083]D
  • Loading branch information
ebrehault authored Mar 7, 2024
1 parent abf4cde commit accdf43
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:

- name: Set version in source
run: |-
sed -i.bak "s#99999.99999.99999#${{ env.PACKAGE_VERSION }}#" electron-app/src/index.ts
rm electron-app/src/index.ts.bak
sed -i "s#99999.99999.99999#${{ env.PACKAGE_VERSION }}#" electron-app/src/index.ts
sed -i 4s/.*/{{ env.PACKAGE_VERSION }}/ electron-app/package.json
- name: Tag if new version
uses: pkgdeps/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- name: Build
run: |-
cd server
VERSION=`cat ../package.json| grep '"version":'`
sed -i 3s/.*/$VERSION/ package.json
npm install
npm run compile
- name: Publish
Expand Down
2 changes: 1 addition & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nuclia-sync-agent",
"productName": "nuclia-sync-agent",
"version": "1.0.10",
"version": "0.0.0",
"description": "This is a Nuclia Sync Agent App",
"main": "build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuclia-sync-agent-app",
"version": "1.0.10",
"version": "1.0.11",
"description": "\"This is a Nuclia Sync Agent App\"",
"main": "build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nuclia/sync-agent",
"version": "1.0.10",
"version": "0.0.0",
"description": "This is a sync agent to synchronize user files from diferent sources to nuclia",
"main": "build/index.js",
"types": "build/types/index.d.ts",
Expand Down
36 changes: 19 additions & 17 deletions server/src/logic/sync/domain/nuclia-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,28 @@ export class NucliaCloud {
}
}

uploadLink(originalId: string, filename: string, data: Link): Observable<void> {
uploadLink(originalId: string, filename: string, data: Link, metadata?: any): Observable<void> {
const slug = sha256(originalId);
const payload: ICreateResource = {
title: filename,
slug,
links: { link: { uri: data.uri } },
origin: { url: data.uri },
icon: 'application/stf-link',
};
if (metadata.labels) {
payload.usermetadata = { classifications: metadata.labels };
}
return this.getKb().pipe(
switchMap((kb) =>
kb
.createOrUpdateResource({
title: filename,
slug,
links: { link: { uri: data.uri } },
origin: { url: data.uri },
icon: 'application/stf-link',
})
.pipe(
retry(RETRY_CONFIG),
delay(500), // do not overload the server
catchError((error) => {
console.log('createOrUpdateResource – error:', JSON.stringify(error));
return of({ success: false, message: '' });
}),
),
kb.createOrUpdateResource(payload).pipe(
retry(RETRY_CONFIG),
delay(500), // do not overload the server
catchError((error) => {
console.log('createOrUpdateResource – error:', JSON.stringify(error));
return of({ success: false, message: '' });
}),
),
),
map(() => undefined),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SyncSingleFile implements SyncSingleFileUseCase {
});
} else if (data.type === 'link' && data.link) {
return nucliaConnector
.uploadLink(item.originalId, item.title, data.link)
.uploadLink(item.originalId, item.title, data.link, { labels: sync.labels })
.pipe(map(() => ({ success: true, message: '' })));
} else {
return of({ success: false, message: '' });
Expand Down

0 comments on commit accdf43

Please sign in to comment.