send not filter to relays that support nip-113
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
export enum Nips {
|
export enum Nips {
|
||||||
Search = 50,
|
Search = 50,
|
||||||
|
NotFilter = 113,
|
||||||
}
|
}
|
||||||
|
@ -324,16 +324,15 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
|
|||||||
this.HandleEvent(e);
|
this.HandleEvent(e);
|
||||||
return e.id;
|
return e.id;
|
||||||
});
|
});
|
||||||
let fCopy = { ...f }; // some relays reject the query if it contains an unknown key. only send locally.
|
|
||||||
if (alreadyHave.length) {
|
if (alreadyHave.length) {
|
||||||
fCopy.not = fCopy.not ?? {};
|
f.not = f.not ?? {};
|
||||||
if (fCopy.not.ids) {
|
if (f.not.ids) {
|
||||||
fCopy.not.ids.push(...alreadyHave);
|
f.not.ids.push(...alreadyHave);
|
||||||
} else {
|
} else {
|
||||||
fCopy.not.ids = alreadyHave;
|
f.not.ids = alreadyHave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.emit("request", fCopy);
|
this.emit("request", f);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (qSend.relay) {
|
if (qSend.relay) {
|
||||||
|
@ -321,6 +321,16 @@ export class Query extends EventEmitter<QueryEvents> implements QueryBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#sendQueryInternal(c: Connection, q: BuiltRawReqFilter) {
|
#sendQueryInternal(c: Connection, q: BuiltRawReqFilter) {
|
||||||
|
if (!c.SupportsNip(Nips.NotFilter)) {
|
||||||
|
q.filters = q.filters.map(f => {
|
||||||
|
if (f.not) {
|
||||||
|
const copy = { ...f };
|
||||||
|
delete copy.not;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
});
|
||||||
|
}
|
||||||
const qt = new QueryTrace(c.Address, q.filters, c.Id);
|
const qt = new QueryTrace(c.Address, q.filters, c.Id);
|
||||||
qt.on("close", x => c.CloseReq(x));
|
qt.on("close", x => c.CloseReq(x));
|
||||||
qt.on("change", () => this.#onProgress());
|
qt.on("change", () => this.#onProgress());
|
||||||
|
Reference in New Issue
Block a user