From db23748dba1d317b6f486b220d40f581d9e44fbe Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Wed, 7 Feb 2024 15:11:32 +0000 Subject: [PATCH] Content doesn't need to be calculated twice. --- src/Connections/FeedConnection.ts | 17 +++++++++-------- src/feeds/FeedReader.ts | 2 -- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Connections/FeedConnection.ts b/src/Connections/FeedConnection.ts index d1aa9b24..26f427f3 100644 --- a/src/Connections/FeedConnection.ts +++ b/src/Connections/FeedConnection.ts @@ -220,15 +220,16 @@ export class FeedConnection extends BaseConnection implements IConnection { // We want to retry these sends, because sometimes the network / HS // craps out. + const content = { + msgtype: 'm.notice', + format: "org.matrix.custom.html", + formatted_body: md.renderInline(message), + body: message, + external_url: entry.link ?? undefined, + "uk.half-shot.matrix-hookshot.feeds.item": entry, + }; await retry( - () => this.intent.sendEvent(this.roomId, { - msgtype: 'm.notice', - format: "org.matrix.custom.html", - formatted_body: md.renderInline(message), - body: message, - external_url: entry.link ?? undefined, - "uk.half-shot.matrix-hookshot.feeds.item": entry, - }), + () => this.intent.sendEvent(this.roomId, content), SEND_EVENT_MAX_ATTEMPTS, SEND_EVENT_INTERVAL_MS, // Filter for showstopper errors like 4XX errors, but otherwise diff --git a/src/feeds/FeedReader.ts b/src/feeds/FeedReader.ts index 04dcda99..81ed7475 100644 --- a/src/feeds/FeedReader.ts +++ b/src/feeds/FeedReader.ts @@ -150,8 +150,6 @@ export class FeedReader { } observedFeedUrls.forEach(url => this.feedQueue.push(url)); this.feedQueue.shuffle(); - - Metrics.feedsCount.set(observedFeedUrls.size); Metrics.feedsCountDeprecated.set(observedFeedUrls.size); return observedFeedUrls;