mirror of
https://github.com/BlowaterNostr/blowater.git
synced 2024-10-18 07:33:22 +00:00
faster content filtering and record urls on new events (#439)
This commit is contained in:
parent
c5cdfed6da
commit
8604dcd405
@ -438,10 +438,15 @@ const handle_update_event = async (chan: PutChannel<true>, args: {
|
||||
}
|
||||
continue;
|
||||
} else if (event.type == "FilterContent") {
|
||||
const pubkey = PublicKey.FromBech32(event.content.trim());
|
||||
const trimmed = event.content.trim();
|
||||
if (trimmed.length == 63) {
|
||||
const pubkey = PublicKey.FromBech32(trimmed);
|
||||
if (pubkey instanceof PublicKey) {
|
||||
sync_user_detail_data({ pool, pubkey, database: app.database });
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
console.log(event, "is not handled");
|
||||
continue;
|
||||
@ -665,7 +670,7 @@ async function sync_user_detail_data(
|
||||
if (msg.res.type == "EOSE") {
|
||||
break;
|
||||
} else if (msg.res.type == "EVENT") {
|
||||
await args.database.addEvent(msg.res.event);
|
||||
await args.database.addEvent(msg.res.event, msg.url);
|
||||
}
|
||||
}
|
||||
await args.pool.closeSub(args.pubkey.bech32());
|
||||
|
@ -17,7 +17,7 @@ export class DexieDatabase extends Dexie implements EventsAdapter, RelayRecorder
|
||||
|
||||
constructor() {
|
||||
super("Events");
|
||||
this.version(20).stores({
|
||||
this.version(22).stores({
|
||||
events: "&id, created_at, kind, tags, pubkey", // indices
|
||||
relayRecords: "[url+event_id]", // RelayRecord
|
||||
eventMarks: "&event_id, reason", // RemoveRecords
|
||||
|
@ -131,9 +131,6 @@ function filter_messages(msgs: ChatMessage[], filter: FilterContent) {
|
||||
const noteID = NoteID.FromBech32(filter_string);
|
||||
const is_note = noteID instanceof NoteID;
|
||||
msgs = msgs.filter((msg) => {
|
||||
if (msg.content.toLocaleLowerCase().indexOf(filter_string) != -1) {
|
||||
return true;
|
||||
}
|
||||
if (is_pubkey) {
|
||||
if (msg.author.hex == pubkey.hex) {
|
||||
return true;
|
||||
@ -144,6 +141,9 @@ function filter_messages(msgs: ChatMessage[], filter: FilterContent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (msg.content.toLocaleLowerCase().indexOf(filter_string) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return msgs;
|
||||
|
Loading…
Reference in New Issue
Block a user