mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -07:00
[widthdrawal] sharkey-react patch
This commit is contained in:
parent
a7e09e479b
commit
ac7b2c643d
1 changed files with 40 additions and 2 deletions
|
@ -24,6 +24,7 @@ import type { UserPublickey } from "@/models/entities/user-publickey.js";
|
|||
import { shouldBlockInstance } from "@/misc/should-block-instance.js";
|
||||
import { verifySignature } from "@/remote/activitypub/check-fetch.js";
|
||||
import { tickInbox } from "@/metrics.js";
|
||||
import punycode from "punycode/";
|
||||
|
||||
const logger = new Logger("inbox");
|
||||
|
||||
|
@ -186,8 +187,8 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
|||
}
|
||||
}
|
||||
|
||||
// Update stats
|
||||
registerOrFetchInstanceDoc(authUser.user.host).then((i) => {
|
||||
// Update stats and get instance metadata
|
||||
const softwareName = await registerOrFetchInstanceDoc(authUser.user.host).then((i) => {
|
||||
Instances.update(i.id, {
|
||||
latestRequestReceivedAt: new Date(),
|
||||
lastCommunicatedAt: new Date(),
|
||||
|
@ -199,8 +200,45 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
|||
instanceChart.requestReceived(i.host);
|
||||
apRequestChart.inbox();
|
||||
federationChart.inbox(i.host);
|
||||
|
||||
return i.softwareName;
|
||||
});
|
||||
|
||||
if (activity.type === 'Like' && ["sharkey", "cutiekey"].includes(softwareName!)) {
|
||||
const emoji = activity._misskey_reaction || activity.content || activity.name;
|
||||
const custom = emoji.match(/^:([\w+-]+)(?:@\.)?:$/);
|
||||
let remove;
|
||||
if (custom) {
|
||||
const name = (custom[1] as string).replaceAll("_", "").toLowerCase();
|
||||
remove = name.includes("heart");
|
||||
} else {
|
||||
const root = punycode.ucs2.decode(emoji)[0];
|
||||
remove = [
|
||||
0x02661, // suit
|
||||
0x02665, // suit black
|
||||
0x02764, // heavy
|
||||
0x1f496, // sparkling
|
||||
0x1f497, // glowing
|
||||
0x1f499, // blue
|
||||
0x1f49a, // green
|
||||
0x1f49b, // yellow
|
||||
0x1f49c, // purple
|
||||
0x1f5a4, // black
|
||||
0x1f90d, // white
|
||||
0x1f90e, // brown
|
||||
0x1f9e1, // orange
|
||||
0x1fa75, // light blue
|
||||
0x1fa76, // grey
|
||||
0x1fa77, // pink
|
||||
].includes(root);
|
||||
}
|
||||
if (remove) {
|
||||
activity._misskey_reaction = undefined;
|
||||
activity.content = undefined;
|
||||
activity.name = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const inbox = authUser.user.sharedInbox ?? authUser.user.inbox;
|
||||
if (inbox !== null) {
|
||||
const { host: inboxHost } = new URL(inbox);
|
||||
|
|
Loading…
Reference in a new issue