Remove issue links from github releases
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Database } from '../shared/Database';
|
import { Database } from '../shared/Database';
|
||||||
|
|
||||||
const mentionRegex = new RegExp('@([\\S]+),|@([\\S]+)', 'gi');
|
const mentionRegex = new RegExp('@([\\S]+),|@([\\S]+)', 'gi');
|
||||||
|
const issueLinkRegex = new RegExp('\\s?\\(\\[(#\\d+)\\]\\(https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_+.~#?&//=]*)\\)', 'gi');
|
||||||
|
|
||||||
export async function fixPings(body: string): Promise<string> {
|
export async function fixPings(body: string): Promise<string> {
|
||||||
const mappings = await Database.getAllGithubUserMappings();
|
const mappings = await Database.getAllGithubUserMappings();
|
||||||
@@ -11,4 +12,8 @@ export async function fixPings(body: string): Promise<string> {
|
|||||||
|
|
||||||
return mapping ? `<@${mapping.discord_id}>` : match;
|
return mapping ? `<@${mapping.discord_id}>` : match;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeIssueLinks(body: string): string {
|
||||||
|
return body.replaceAll(issueLinkRegex, '');
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Client } from 'discord.js';
|
import { Client } from 'discord.js';
|
||||||
import bodyParser from 'body-parser';
|
import bodyParser from 'body-parser';
|
||||||
import { fixPings } from '../utils/github-user-utils';
|
import { fixPings, removeIssueLinks } from '../utils/github-user-utils';
|
||||||
import { logDebug } from '../utils/debug-utils';
|
import { logDebug } from '../utils/debug-utils';
|
||||||
import { AltData, comprehensiveAltLookupFromE621 } from '../utils';
|
import { AltData, comprehensiveAltLookupFromE621 } from '../utils';
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ async function handleGithubRelease(client: Client, req: Request, res: Response):
|
|||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
let message = `## [${months[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}](<${data.release.html_url}>)\n\n${await fixPings(data.release.body)}`;
|
let message = `## [${months[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}](<${data.release.html_url}>)\n\n${await fixPings(removeIssueLinks(data.release.body))}`;
|
||||||
|
|
||||||
logDebug('Sending github release message');
|
logDebug('Sending github release message');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user