fix(streaming): move get muted users logic before upgrading connection to web socket
This commit is contained in:
parent
b626d75262
commit
4d342dff4a
|
@ -50,6 +50,16 @@ const streamingController: AppController = async (c) => {
|
|||
return c.json({ error: 'Invalid access token' }, 401);
|
||||
}
|
||||
|
||||
const mutedUsersSet = new Set();
|
||||
if (pubkey) {
|
||||
const [mutedUsers] = await Storages.admin.query([{ authors: [pubkey], kinds: [10000], limit: 1 }], { signal });
|
||||
if (mutedUsers) {
|
||||
for (const pubkey of getTagSet(mutedUsers.tags, 'p')) {
|
||||
mutedUsersSet.add(pubkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { socket, response } = Deno.upgradeWebSocket(c.req.raw, { protocol: token });
|
||||
|
||||
function send(name: string, payload: object) {
|
||||
|
@ -63,16 +73,6 @@ const streamingController: AppController = async (c) => {
|
|||
}
|
||||
}
|
||||
|
||||
const mutedUsersSet = new Set();
|
||||
if (pubkey) {
|
||||
const [mutedUsers] = await Storages.admin.query([{ authors: [pubkey], kinds: [10000], limit: 1 }], { signal });
|
||||
if (mutedUsers) {
|
||||
for (const pubkey of getTagSet(mutedUsers.tags, 'p')) {
|
||||
mutedUsersSet.add(pubkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
socket.onopen = async () => {
|
||||
if (!stream) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue