Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 Fix 500 error on badge recovery #2050

Merged
merged 3 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions twake/backend/node/src/cli/cmds/search_cmds/index_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class SearchIndexAll {
count += list.getEntities().length;
await new Promise(r => setTimeout(r, 200));
} while (page.page_token);

console.log("Emptying flush (10s)...");
await new Promise(r => setTimeout(r, 10000));

console.log("Done!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,25 @@ export class UserNotificationBadgeService implements UserNotificationBadgeServic
for (const badge of badgePerWorkspace) {
const workspaceId = badge.workspace_id;
const companyId = badge.company_id;
const exists = await this.userService.workspaces.getUser({
workspaceId,
userId,
});
if (!exists) {
await this.channelsService.members.ensureUserNotInWorkspaceIsNotInChannel(
{ id: userId },
{ id: workspaceId, company_id: companyId },
);
for (const badge of badges.getEntities()) {
if (badge.workspace_id === workspaceId) this.removeUserChannelBadges(badge);
}
badges.filterEntities(b => b.workspace_id === workspaceId);
if (workspaceId === "direct") {
continue;
}
try {
const exists = await this.userService.workspaces.getUser({
workspaceId,
userId,
});
if (!exists) {
await this.channelsService.members.ensureUserNotInWorkspaceIsNotInChannel(
{ id: userId },
{ id: workspaceId, company_id: companyId },
);
for (const badge of badges.getEntities()) {
if (badge.workspace_id === workspaceId) this.removeUserChannelBadges(badge);
}
badges.filterEntities(b => b.workspace_id === workspaceId);
}
} catch (e) {}
}

return badges;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
" " +
entity.last_name +
" " +
entity.email_canonical.split("@")[0] +
(entity.email_canonical || "").split("@")[0] +
" " +
entity.username_canonical,
),
Expand Down