Skip to content

Commit

Permalink
#3044 checking for notFound error and changed how we get org id
Browse files Browse the repository at this point in the history
  • Loading branch information
chpy04 committed Dec 22, 2024
1 parent 05e984c commit 74b287f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/backend/src/controllers/slack.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default class SlackController {
try {
const organizations = await OrganizationsService.getAllOrganizations();
const nerSlackWorkspaceId = await getWorkspaceId();
const orgId = organizations.find((org) => org.slackWorkspaceId === nerSlackWorkspaceId)?.organizationId;
if (orgId) {
slackServices.processMessageSent(event, orgId);
const relatedOrganization = organizations.find((org) => org.slackWorkspaceId === nerSlackWorkspaceId);
if (relatedOrganization) {
slackServices.processMessageSent(event, relatedOrganization.organizationId);
}
} catch (error: unknown) {}
}
Expand Down
8 changes: 7 additions & 1 deletion src/backend/src/services/slack.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AnnouncementService from './announcement.service';
import { Announcement } from 'shared';
import prisma from '../prisma/prisma';
import { blockToMentionedUsers, blockToString } from '../utils/slack.utils';
import { NotFoundException } from '../utils/errors.utils';

/**
* Represents a slack event for a message in a channel.
Expand Down Expand Up @@ -159,7 +160,12 @@ export default class slackServices {
slackChannelName,
organizationId
);
} catch (ignored) {}
} catch (error) {
//if couldn't find the announcement to edit, create a new one below
if (!(error instanceof NotFoundException)) {
throw error;
}
}
}
return await AnnouncementService.createAnnouncement(
messageText,
Expand Down

0 comments on commit 74b287f

Please sign in to comment.