Skip to content

Commit

Permalink
fix: findFeed && user deactiveated
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Nov 27, 2020
1 parent fa42f40 commit d3fe70f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 6 additions & 3 deletions source/utils/feed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { none, Option, Optional } from '../types/option';
import { TRSS, parseString } from '../parser/parse';
import { parseString, TRSS } from '../parser/parse';

export async function isFeedValid(feedStr: string): Promise<Option<TRSS>> {
try {
const feed = await parseString(feedStr);
Expand All @@ -15,7 +16,10 @@ export async function findFeed(
): Promise<string[]> {
const reqURL = new URL(reqUrl);
const linksTag = html.match(/<link[^>]+rel="alternate"[^>]+\/?>/g);
const urls = linksTag
if (!linksTag) {
return [];
}
return linksTag
.filter((t) => t.match(/rss|atom/) && t.includes('href'))
.map((linkTag) => {
const url = linkTag.match(/href="(.+?)"/)[1];
Expand All @@ -26,5 +30,4 @@ export async function findFeed(
return reqURL.toString();
}
});
return urls;
}
4 changes: 1 addition & 3 deletions source/utils/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import { isNone } from '../types/option';
async function handlerSendError(e: any, userId: number): Promise<boolean> {
// bot was blocked or chat is deleted
logger.error(e);
const re = new RegExp(
'chat not found|bot was blocked by the user|bot was kicked'
);
const re = /chat not found|bot was blocked by the user|bot was kicked|user is deactivated/;
if (config.delete_on_err_send && re.test(e.description)) {
logger.error(`delete all subscribes for user ${userId}`);
deleteSubscribersByUserId(userId);
Expand Down

0 comments on commit d3fe70f

Please sign in to comment.