From 6da7382b0763ac3c1075d78b0d10f831a193163b Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 4 Aug 2020 11:25:33 -0300 Subject: [PATCH 1/4] Fix sending notification from senders without name --- app/lib/server/functions/notifications/mobile.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/lib/server/functions/notifications/mobile.js b/app/lib/server/functions/notifications/mobile.js index 02e5cb4d4f814..4d1b7482b1265 100644 --- a/app/lib/server/functions/notifications/mobile.js +++ b/app/lib/server/functions/notifications/mobile.js @@ -42,10 +42,7 @@ function enableNotificationReplyButton(room, username) { } export async function getPushData({ room, message, userId, senderUsername, senderName, notificationMessage, receiver, shouldOmitMessage = true }) { - let username = ''; - if (settings.get('Push_show_username_room')) { - username = settings.get('UI_Use_Real_Name') === true ? senderName : senderUsername; - } + const username = (settings.get('Push_show_username_room') && settings.get('UI_Use_Real_Name') && senderName) || senderUsername; const lng = receiver.language || settings.get('Language') || 'en'; From 217b73faf1afe07e4063b5c787c7756d60e9784c Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 4 Aug 2020 11:45:20 -0300 Subject: [PATCH 2/4] Remove CodeQL --- .github/workflows/codeql-analysis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a88b2a63f8137..de9c66fda36ea 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,8 +1,6 @@ name: "Code scanning - action" on: - push: - pull_request: schedule: - cron: '0 13 * * *' @@ -24,7 +22,7 @@ jobs: # the head of the pull request instead of the merge commit. - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 From ee96c388fc6a489f52c0d07bd29da68153ff6aa8 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 4 Aug 2020 21:31:54 -0300 Subject: [PATCH 3/4] Save error and skip from queue --- app/models/server/models/NotificationQueue.js | 1 + app/models/server/raw/NotificationQueue.ts | 15 +++++++++++++++ .../server/NotificationQueue.ts | 2 +- definition/INotification.ts | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/server/models/NotificationQueue.js b/app/models/server/models/NotificationQueue.js index 1210f5e73127f..32eb7524c2c29 100644 --- a/app/models/server/models/NotificationQueue.js +++ b/app/models/server/models/NotificationQueue.js @@ -7,6 +7,7 @@ export class NotificationQueue extends Base { this.tryEnsureIndex({ ts: 1 }, { expireAfterSeconds: 2 * 60 * 60 }); this.tryEnsureIndex({ schedule: 1 }, { sparse: true }); this.tryEnsureIndex({ sending: 1 }, { sparse: true }); + this.tryEnsureIndex({ error: 1 }, { sparse: true }); } } diff --git a/app/models/server/raw/NotificationQueue.ts b/app/models/server/raw/NotificationQueue.ts index 136671fba372f..44a34a21be7f5 100644 --- a/app/models/server/raw/NotificationQueue.ts +++ b/app/models/server/raw/NotificationQueue.ts @@ -18,6 +18,19 @@ export class NotificationQueueRaw extends BaseRaw { }); } + setErrorById(_id: string, error: any) { + return this.col.updateOne({ + _id, + }, { + $set: { + error, + }, + $unset: { + sending: 1, + }, + }); + } + removeById(_id: string) { return this.col.deleteOne({ _id }); } @@ -55,6 +68,8 @@ export class NotificationQueueRaw extends BaseRaw { { schedule: { $exists: false } }, { schedule: { $lte: now } }, ], + }, { + error: { $exists: false }, }], }, { $set: { diff --git a/app/notification-queue/server/NotificationQueue.ts b/app/notification-queue/server/NotificationQueue.ts index 1927d888c2283..7665a588c8ee0 100644 --- a/app/notification-queue/server/NotificationQueue.ts +++ b/app/notification-queue/server/NotificationQueue.ts @@ -75,7 +75,7 @@ class NotificationClass { NotificationQueue.removeById(notification._id); } catch (e) { console.error(e); - await NotificationQueue.unsetSendingById(notification._id); + await NotificationQueue.setErrorById(notification._id, e.message); } if (counter >= this.maxBatchSize) { diff --git a/definition/INotification.ts b/definition/INotification.ts index 6359f33dd612c..d8153de9427fe 100644 --- a/definition/INotification.ts +++ b/definition/INotification.ts @@ -40,5 +40,6 @@ export interface INotification { ts: Date; schedule?: Date; sending?: Date; + error?: string; items: NotificationItem[]; } From 708eb154ddecd6bc61a445527e1c3007b7ffcadc Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 4 Aug 2020 21:33:06 -0300 Subject: [PATCH 4/4] Add CodeQL back --- .github/workflows/codeql-analysis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index de9c66fda36ea..da9570060ed49 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,6 +1,8 @@ name: "Code scanning - action" on: + push: + pull_request: schedule: - cron: '0 13 * * *'