Skip to content

Commit

Permalink
[FIX] Desktop notification on multi-instance environments (#25220)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Apr 19, 2022
1 parent 154bc18 commit e419108
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/meteor/app/notifications/server/lib/Notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DDPCommon } from 'meteor/ddp-common';

import { NotificationsModule } from '../../../../server/modules/notifications/notifications.module';
import { Streamer } from '../../../../server/modules/streamer/streamer.module';
import { api } from '../../../../server/sdk/api';
import {
Subscriptions as SubscriptionsRaw,
Rooms as RoomsRaw,
Expand Down Expand Up @@ -41,4 +42,8 @@ notifications.configure({
Settings: SettingsRaw,
});

notifications.streamLocal.on('broadcast', ({ eventName, args }) => {
api.broadcastLocal(eventName, ...args);
});

export default notifications;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class NotificationsModule {

public readonly streamRoomData: IStreamer;

public readonly streamLocal: IStreamer;

public readonly streamPresence: IStreamer;

constructor(private Streamer: IStreamerConstructor) {
Expand Down Expand Up @@ -91,6 +93,7 @@ export class NotificationsModule {
});

this.streamUser = new this.Streamer('notify-user');
this.streamLocal = new this.Streamer('local');
}

async configure({ Rooms, Subscriptions, Users, Settings }: IModelsParam): Promise<void> {
Expand Down Expand Up @@ -446,6 +449,11 @@ export class NotificationsModule {
}
});

this.streamLocal.serverOnly = true;
this.streamLocal.allowRead('none');
this.streamLocal.allowEmit('all');
this.streamLocal.allowWrite('none');

this.streamPresence.allowRead('logged');
this.streamPresence.allowWrite('none');
}
Expand Down

0 comments on commit e419108

Please sign in to comment.