Skip to content

Commit

Permalink
Merge pull request RocketChat#359 from WideChat/karan_pwa_develop
Browse files Browse the repository at this point in the history
Resolve pwa-push merge conflicts.
  • Loading branch information
ear-dev authored Jul 20, 2020
2 parents 73b7d93 + 4cd441d commit 5c6d2d6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,23 @@ API.v1.addRoute('chat.pinMessage', { authRequired: true }, {

API.v1.addRoute('chat.postMessage', { authRequired: true }, {
post() {
const messageReturn = processWebhookMessage(this.bodyParams, this.user)[0];
// WIDECHAT only
let messageReturn;
if (this.user.username === settings.get('Notification_Service_User_Username')) {
const { hostname_id } = this.requestParams();
if (!hostname_id) {
throw new Meteor.Error('error-hostname-id-not-provided', 'Body param "hostname_id" is required');
}
const hostuser = Users.findOneById(hostname_id);
messageReturn = processWebhookMessage(this.bodyParams, hostuser, undefined, true)[0];
} else {
messageReturn = processWebhookMessage(this.bodyParams, this.user, undefined, true)[0];
}
//

// RC code
// const messageReturn = processWebhookMessage(this.bodyParams, this.user)[0];


if (!messageReturn) {
return API.v1.failure('unknown-error');
Expand Down
1 change: 1 addition & 0 deletions app/lib/server/functions/insertMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const insertMessage = function(user, message, room, upsert = false) {
alias: String,
emoji: String,
avatar: String,
pushm: Boolean,
attachments: [Match.Any],
}));

Expand Down
5 changes: 5 additions & 0 deletions app/lib/server/functions/processWebhookMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export const processWebhookMessage = function(messageObj, user, defaultValues =
}, error);
}

if (messageObj.pushm && messageObj.pushm === 'true') {
message.pushm = true;
message.pushm_encrypted = true;
}

const messageReturn = sendMessage(user, message, room);
sentData.push({ channel, message: messageReturn });
}
Expand Down
8 changes: 8 additions & 0 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,14 @@ settings.addGroup('General', function() {
public: true,
i18nDescription: 'Notifications_Max_Room_Members_Description',
});
this.add('Notifications_Always_Notify_Mobile', false, {
type: 'boolean',
public: true,
i18nDescription: 'Notifications_Always_Notify_Mobile_Description',
});
this.add('Notification_Service_User_Username', 'viasat.notification.service', {
type: 'string',
});
});
this.section('REST API', function() {
return this.add('API_User_Limit', 500, {
Expand Down
4 changes: 4 additions & 0 deletions app/models/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class Messages extends Base {
this.tryEnsureIndex({ tcount: 1, tlm: 1 }, { sparse: true });
// livechat
this.tryEnsureIndex({ 'navigation.token': 1 }, { sparse: true });

// push-message
this.tryEnsureIndex({ pushm: 1 }, { sparse: true });
this.tryEnsureIndex({ pushm_encrypted: 1 }, { sparse: true });
}

setReactions(messageId, reactions) {
Expand Down

0 comments on commit 5c6d2d6

Please sign in to comment.