mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
resolve userids
This commit is contained in:
parent
a8b7b0ba1a
commit
2223571f6a
1 changed files with 15 additions and 1 deletions
|
|
@ -201,12 +201,19 @@ async function performSync(): Promise<void> {
|
|||
await ensureRun();
|
||||
totalMessages += messages.length;
|
||||
|
||||
// Batch-resolve unknown user IDs
|
||||
// Batch-resolve unknown user IDs (from authors + @mentions in content)
|
||||
const unknownIds = new Set<string>();
|
||||
const mentionPattern = /<@(U[A-Z0-9]+)>/g;
|
||||
for (const msg of messages) {
|
||||
if (msg.author?.user_id && !state.userCache[msg.author.user_id]) {
|
||||
unknownIds.add(msg.author.user_id);
|
||||
}
|
||||
let match;
|
||||
while ((match = mentionPattern.exec(msg.content)) !== null) {
|
||||
if (!state.userCache[match[1]]) {
|
||||
unknownIds.add(match[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const userId of unknownIds) {
|
||||
|
|
@ -219,6 +226,13 @@ async function performSync(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
// Replace @mentions in message content with resolved names
|
||||
for (const msg of messages) {
|
||||
msg.content = msg.content.replace(/<@(U[A-Z0-9]+)>/g, (_: string, id: string) => {
|
||||
return `@${state.userCache[id] || id}`;
|
||||
});
|
||||
}
|
||||
|
||||
// Build and write markdown
|
||||
const wsName = workspaceNameFromUrl(workspace.url);
|
||||
const md = buildMarkdown(workspace.url, workspace.name || wsName, messages, state.userCache);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue