mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 13:17:08 +00:00
Fix feed.success crashing the process due to a typing issue (#469)
* Fix feed.sucess * changelog * Stop being lazy and use an interface
This commit is contained in:
parent
e0dadd4ad3
commit
79f28f3ae0
1
changelog.d/469.bugfix
Normal file
1
changelog.d/469.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix a bug where reading RSS feeds could crash the process.
|
@ -40,7 +40,7 @@ import { getAppservice } from "./appservice";
|
||||
import { JiraOAuthRequestCloud, JiraOAuthRequestOnPrem, JiraOAuthRequestResult } from "./Jira/OAuth";
|
||||
import { GenericWebhookEvent, GenericWebhookEventResult } from "./generic/types";
|
||||
import { SetupWidget } from "./Widgets/SetupWidget";
|
||||
import { FeedEntry, FeedError, FeedReader } from "./feeds/FeedReader";
|
||||
import { FeedEntry, FeedError, FeedReader, FeedSuccess } from "./feeds/FeedReader";
|
||||
const log = new LogWrapper("Bridge");
|
||||
|
||||
export class Bridge {
|
||||
@ -615,9 +615,9 @@ export class Bridge {
|
||||
(data) => connManager.getConnectionsForFeedUrl(data.feed.url),
|
||||
(c, data) => c.handleFeedEntry(data),
|
||||
);
|
||||
this.bindHandlerToQueue<FeedEntry, FeedConnection>(
|
||||
this.bindHandlerToQueue<FeedSuccess, FeedConnection>(
|
||||
"feed.success",
|
||||
(data) => connManager.getConnectionsForFeedUrl(data.feed.url),
|
||||
(data) => connManager.getConnectionsForFeedUrl(data.url),
|
||||
c => c.handleFeedSuccess(),
|
||||
);
|
||||
this.bindHandlerToQueue<FeedError, FeedConnection>(
|
||||
|
@ -55,6 +55,10 @@ export interface FeedEntry {
|
||||
fetchKey: string,
|
||||
}
|
||||
|
||||
export interface FeedSuccess {
|
||||
url: string,
|
||||
}
|
||||
|
||||
interface AccountData {
|
||||
[url: string]: string[],
|
||||
}
|
||||
@ -210,7 +214,7 @@ export class FeedReader {
|
||||
const entry = {
|
||||
feed: {
|
||||
title: feed.title ? stripHtml(feed.title) : null,
|
||||
url: url.toString()
|
||||
url: url,
|
||||
},
|
||||
title: item.title ? stripHtml(item.title) : null,
|
||||
link: item.link || null,
|
||||
@ -233,7 +237,7 @@ export class FeedReader {
|
||||
const newSeenItems = Array.from(new Set([ ...newGuids, ...seenGuids ]).values()).slice(0, maxGuids);
|
||||
this.seenEntries.set(url, newSeenItems);
|
||||
}
|
||||
this.queue.push<undefined>({ eventName: 'feed.success', sender: 'FeedReader', data: undefined});
|
||||
this.queue.push<FeedSuccess>({ eventName: 'feed.success', sender: 'FeedReader', data: { url: url } });
|
||||
} catch (err: unknown) {
|
||||
const error = err instanceof Error ? err : new Error(`Unknown error ${err}`);
|
||||
const feedError = new FeedError(url.toString(), error, fetchKey);
|
||||
|
Loading…
x
Reference in New Issue
Block a user