Skip to content

Commit

Permalink
[IMPROVE] [Apps-Engine] App user as the default notifier (#17050)
Browse files Browse the repository at this point in the history
* App user as the default notifier

* Move changes to the apps-engine side

Co-authored-by: Douglas Gubert <d-gubert@users.noreply.github.com>
  • Loading branch information
Shiqi Mei and d-gubert committed May 1, 2020
1 parent 629cbfb commit 40e2f53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions app/apps/server/bridges/messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Random } from 'meteor/random';

import { Messages, Users, Subscriptions } from '../../../models';
import { Messages, Users, Subscriptions } from '../../../models/server';
import { Notifications } from '../../../notifications';
import { updateMessage } from '../../../lib/server/functions/updateMessage';
import { executeSendMessage } from '../../../lib/server/methods/sendMessage';
Expand Down Expand Up @@ -48,12 +48,15 @@ export class AppMessageBridge {

const msg = this.orch.getConverters().get('messages').convertAppMessage(message);

Notifications.notifyUser(user.id, 'message', Object.assign(msg, {
if (!msg) {
return;
}

Notifications.notifyUser(user.id, 'message', {
...msg,
_id: Random.id(),
ts: new Date(),
u: undefined,
editor: undefined,
}));
});
}

async notifyRoom(room, message, appId) {
Expand All @@ -68,8 +71,6 @@ export class AppMessageBridge {
_id: Random.id(),
rid: room.id,
ts: new Date(),
u: undefined,
editor: undefined,
});

const users = Subscriptions.findByRoomIdWhenUserIdExists(room.id, { fields: { 'u._id': 1 } })
Expand Down
2 changes: 1 addition & 1 deletion app/apps/server/converters/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class AppMessagesConverter {
}

convertAppMessage(message) {
if (!message) {
if (!message || !message.room) {
return undefined;
}

Expand Down

0 comments on commit 40e2f53

Please sign in to comment.