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 authored and d-gubert committed Apr 19, 2022
1 parent e8cb666 commit 7e8ece3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 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;
8 changes: 8 additions & 0 deletions server/modules/notifications/notifications.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class NotificationsModule {

public readonly streamRoomData: IStreamer;

public readonly streamLocal: IStreamer;

public readonly streamPresence: IStreamer;

constructor(private Streamer: IStreamerConstructor) {
Expand Down Expand Up @@ -93,6 +95,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 @@ -448,6 +451,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 7e8ece3

Please sign in to comment.