Skip to content

Commit

Permalink
Update ws.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
BlowaterNostr committed May 1, 2024
1 parent 745b962 commit 762f938
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ async function handle_cmd_event(args: {
connections,
)
) {
console.log(policy);
if (policy.read === false) {
return;
}
Expand All @@ -205,19 +204,26 @@ async function handle_cmd_req(
resolvePolicyByKind: func_ResolvePolicyByKind;
} & EventReadWriter,
) {
const { this_socket, resolvePolicyByKind, get_events_by_IDs } = args;
const { this_socket } = args;
const sub_id = nostr_ws_msg[1];
const filters = nostr_ws_msg.slice(2) as NostrFilter[];

args.connections.get(this_socket)?.set(
sub_id,
filters.map((f) => {
return {
filter: f,
eventSent: 0,
};
}),
);
const subscriptions = args.connections.get(this_socket)
if(subscriptions) {
if(subscriptions.size > 10) {
send(this_socket, JSON.stringify(respond_notice(`${sub_id}:only accept at most 10 subscriptions`)));
return;
}
subscriptions.set(
sub_id,
filters.map((f) => {
return {
filter: f,
eventSent: 0,
};
}),
);
}

// query this filter
for (const filter of filters) {
Expand Down

0 comments on commit 762f938

Please sign in to comment.