diff --git a/packages/client-core/src/social/services/ChannelService.ts b/packages/client-core/src/social/services/ChannelService.ts index b4af7a74d4..63b6c00116 100755 --- a/packages/client-core/src/social/services/ChannelService.ts +++ b/packages/client-core/src/social/services/ChannelService.ts @@ -97,6 +97,10 @@ export const ChannelService = { }) channelState.merge({ messageCreated: true }) } catch (err) { + //Occasionally, the client attempts to fetch the instance's channel after it's been created, but before the user's + //channel-user has been created, which occurs when connecting to the instance server. + //If it's a 403, it is almost definitely because of this issue, so just wait a second and try again. + if (err.code == 403) return setTimeout(() => ChannelService.getInstanceChannel(), 1000) NotificationService.dispatchNotify(err.message, { variant: 'error' }) } }, diff --git a/packages/server-core/src/hooks/channel-permission-authenticate.ts b/packages/server-core/src/hooks/channel-permission-authenticate.ts index f983f36ae5..56ff3db2af 100755 --- a/packages/server-core/src/hooks/channel-permission-authenticate.ts +++ b/packages/server-core/src/hooks/channel-permission-authenticate.ts @@ -42,13 +42,13 @@ export default () => { if (channel == null) { throw new BadRequest('Invalid channel ID') } - const partyUser = await app.service('channel-user').Model.findOne({ + const channelUser = await app.service('channel-user').Model.findOne({ where: { channelId: channel.id, userId: userId } }) - if (partyUser == null) { + if (channelUser == null) { throw new Forbidden('You are not a member of that channel') } return context