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] Desktop notification on multi-instance environments #25220

Merged
merged 1 commit into from
Apr 19, 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
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