Skip to content

Commit 08b40db

Browse files
committed
sync user with salesloft after adding tag
1 parent 49d53a0 commit 08b40db

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/packages/conat/hub/api/system.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const system = {
2323
deletePassport: authFirst,
2424

2525
adminSalesloftSync: authFirst,
26+
userSalesloftSync: authFirst,
2627
};
2728

2829
export interface System {
@@ -103,6 +104,8 @@ export interface System {
103104
account_ids: string[];
104105
}) => Promise<void>;
105106

107+
userSalesloftSync: (opts: { account_id?: string }) => Promise<void>;
108+
106109
sendEmailVerification: (opts: {
107110
account_id?: string;
108111
only_verify?: boolean;

src/packages/frontend/account/actions.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export class AccountActions extends Actions<AccountState> {
245245
this.setState({ fragment });
246246
};
247247

248-
addTag = (tag: string) => {
248+
addTag = async (tag: string) => {
249249
const store = this.redux.getStore("account");
250250
if (!store) return;
251251
const tags = store.get("tags");
@@ -258,6 +258,15 @@ export class AccountActions extends Actions<AccountState> {
258258
const v = tags?.toJS() ?? [];
259259
v.push(tag);
260260
table.set({ tags: v });
261+
try {
262+
await webapp_client.conat_client.hub.system.userSalesloftSync({});
263+
} catch (err) {
264+
console.warn(
265+
"WARNING: issue syncing with salesloft after setting tag",
266+
tag,
267+
err,
268+
);
269+
}
261270
};
262271

263272
// delete won't be visible in frontend until a browser refresh...

src/packages/server/conat/api/system.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import search from "@cocalc/server/accounts/search";
1010
export { getNames } from "@cocalc/server/accounts/get-name";
1111
import { callback2 } from "@cocalc/util/async-utils";
1212
import getLogger from "@cocalc/backend/logger";
13+
import { reuseInFlight } from "@cocalc/util/reuse-in-flight";
1314

1415
const logger = getLogger("server:conat:api:system");
1516

@@ -154,3 +155,12 @@ export async function adminSalesloftSync({
154155
}
155156
})();
156157
}
158+
159+
// user can sync themself with salesloft.
160+
export const userSalesloftSync = reuseInFlight(
161+
async ({ account_id }: { account_id?: string }): Promise<void> => {
162+
if (account_id) {
163+
await salesloftSync([account_id]);
164+
}
165+
},
166+
);

0 commit comments

Comments
 (0)