mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 14:51:52 +00:00
refactor: tighten Buzz directory bounds
This commit is contained in:
@@ -206,7 +206,11 @@ export function startBuzzDirectoryRelay(params: {
|
||||
return refreshInFlight;
|
||||
}
|
||||
refreshInFlight = (async () => {
|
||||
while (pendingRoomIds.size > 0 && !closed && !params.signal?.aborted) {
|
||||
while (pendingRoomIds.size > 0) {
|
||||
if (closed || params.signal?.aborted) {
|
||||
pendingRoomIds.clear();
|
||||
return;
|
||||
}
|
||||
const nextRoomIds = [...pendingRoomIds];
|
||||
pendingRoomIds.clear();
|
||||
await queryBuzzDirectoryRooms({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Event } from "nostr-tools";
|
||||
import type { ChannelDirectoryEntry } from "openclaw/plugin-sdk/directory-runtime";
|
||||
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
||||
import type { BuzzRoomMembership } from "./room-membership.js";
|
||||
import { buildBuzzTarget, parseBuzzTarget } from "./target.js";
|
||||
|
||||
@@ -39,7 +40,7 @@ function normalizeBoundedString(value: unknown, maxChars: number): string | unde
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
}
|
||||
return [...trimmed].slice(0, maxChars).join("");
|
||||
return truncateUtf16Safe(trimmed, maxChars);
|
||||
}
|
||||
|
||||
function readPreferredString(params: {
|
||||
@@ -301,14 +302,12 @@ export class BuzzDirectoryState {
|
||||
const entries = [...membership.members]
|
||||
.map((publicKey) => {
|
||||
const entry = this.#buildUserEntry(publicKey);
|
||||
return {
|
||||
...entry,
|
||||
raw: {
|
||||
publicKey,
|
||||
role: membership.roles.get(publicKey),
|
||||
roomId,
|
||||
},
|
||||
} satisfies ChannelDirectoryEntry;
|
||||
entry.raw = {
|
||||
publicKey,
|
||||
role: membership.roles.get(publicKey),
|
||||
roomId,
|
||||
};
|
||||
return entry;
|
||||
})
|
||||
.toSorted(compareDirectoryEntries);
|
||||
return applyQueryAndLimit(entries, { limit: params.limit });
|
||||
|
||||
Reference in New Issue
Block a user