Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,42 @@
import { UserGroupJoinings, UserGroups, Users } from "../models/index.js";
import { In } from "typeorm";
const GROUP_MENTION = /(^|[^\w@])@@([a-zA-Z0-9_]{1,64})\b/g;
const WRAPPED_ASSET = /[:;][^:;\s]{1,100}[:;]/g;
export function extractGroupMentionNames(texts) {
const names = new Set();
for (const text of texts){
if (!text) continue;
const sanitized = text.replace(WRAPPED_ASSET, (match)=>" ".repeat(match.length));
for (const match of sanitized.matchAll(GROUP_MENTION)){
names.add(match[2].toLowerCase());
}
}
return [
...names
];
}
export async function extractGroupMentionedUsers(texts) {
const names = extractGroupMentionNames(texts);
if (names.length === 0) return [];
const groups = await UserGroups.find({
where: names.map((username)=>({
username
}))
});
const mentionedUserIds = new Set();
for (const group of groups){
mentionedUserIds.add(group.userId);
const joinings = await UserGroupJoinings.findBy({
userGroupId: group.id
});
for (const joining of joinings){
mentionedUserIds.add(joining.userId);
}
}
if (mentionedUserIds.size === 0) return [];
return await Users.findBy({
id: In([
...mentionedUserIds
])
});
}