mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 00:11:01 +00:00
Send tags into spam filter
This commit is contained in:
parent
f21edd8e4d
commit
4145ba8a1c
@ -29,16 +29,17 @@
|
|||||||
// caller - a string that is one of "Process", "Thread",
|
// caller - a string that is one of "Process", "Thread",
|
||||||
// "Inbox" or "Global" indicating which part of
|
// "Inbox" or "Global" indicating which part of
|
||||||
// the code is running your script
|
// the code is running your script
|
||||||
// content - the event content as a string
|
|
||||||
// id - the event ID, as a hex string
|
// id - the event ID, as a hex string
|
||||||
|
// pubkey - the event author public key, as a hex string
|
||||||
// kind - the event kind as an integer
|
// kind - the event kind as an integer
|
||||||
|
// tags - the event tags (array of array of strings)
|
||||||
|
// content - the event content as a string
|
||||||
// muted - if the author is in your mute list
|
// muted - if the author is in your mute list
|
||||||
// name - if we have it, the name of the author (or your
|
// name - if we have it, the name of the author (or your
|
||||||
// petname), else an empty string
|
// petname), else an empty string
|
||||||
// nip05valid - whether nip05 is valid for the author, as a
|
// nip05valid - whether nip05 is valid for the author, as a
|
||||||
// boolean
|
// boolean
|
||||||
// pow - the Proof of Work on the event
|
// pow - the Proof of Work on the event
|
||||||
// pubkey - the event author public key, as a hex string
|
|
||||||
// seconds_known - the number of seconds that the author of the
|
// seconds_known - the number of seconds that the author of the
|
||||||
// event has been known to gossip
|
// event has been known to gossip
|
||||||
// spamsafe - true only if the event came in from a relay
|
// spamsafe - true only if the event came in from a relay
|
||||||
|
@ -2,7 +2,7 @@ use crate::globals::GLOBALS;
|
|||||||
use crate::people::PersonList;
|
use crate::people::PersonList;
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
use crate::storage::{PersonTable, Table};
|
use crate::storage::{PersonTable, Table};
|
||||||
use nostr_types::{Event, EventKind, Id, PublicKey, Unixtime};
|
use nostr_types::{Event, EventKind, Id, PublicKey, Tag, Unixtime};
|
||||||
use rhai::{CallFnOptions, Engine, Scope, AST};
|
use rhai::{CallFnOptions, Engine, Scope, AST};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ pub fn filter_event(event: Event, caller: EventFilterCaller, spamsafe: bool) ->
|
|||||||
rumor.pubkey,
|
rumor.pubkey,
|
||||||
rumor.kind,
|
rumor.kind,
|
||||||
rumor.content,
|
rumor.content,
|
||||||
|
rumor.tags,
|
||||||
pow,
|
pow,
|
||||||
caller,
|
caller,
|
||||||
spamsafe,
|
spamsafe,
|
||||||
@ -81,6 +82,7 @@ pub fn filter_event(event: Event, caller: EventFilterCaller, spamsafe: bool) ->
|
|||||||
event.pubkey,
|
event.pubkey,
|
||||||
event.kind,
|
event.kind,
|
||||||
event.content,
|
event.content,
|
||||||
|
event.tags,
|
||||||
pow,
|
pow,
|
||||||
caller,
|
caller,
|
||||||
spamsafe,
|
spamsafe,
|
||||||
@ -93,6 +95,7 @@ fn inner_filter(
|
|||||||
pubkey: PublicKey,
|
pubkey: PublicKey,
|
||||||
kind: EventKind,
|
kind: EventKind,
|
||||||
content: String,
|
content: String,
|
||||||
|
mut tags: Vec<Tag>,
|
||||||
pow: u8,
|
pow: u8,
|
||||||
caller: EventFilterCaller,
|
caller: EventFilterCaller,
|
||||||
spamsafe: bool,
|
spamsafe: bool,
|
||||||
@ -117,6 +120,8 @@ fn inner_filter(
|
|||||||
return EventFilterAction::Allow;
|
return EventFilterAction::Allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tags: Vec<Vec<String>> = tags.drain(..).map(|t| t.into_inner()).collect();
|
||||||
|
|
||||||
// NOTE numbers in rhai are i64 or f32
|
// NOTE numbers in rhai are i64 or f32
|
||||||
let mut scope = Scope::new();
|
let mut scope = Scope::new();
|
||||||
scope
|
scope
|
||||||
@ -124,6 +129,7 @@ fn inner_filter(
|
|||||||
.push_constant("pubkey", pubkey.as_hex_string())
|
.push_constant("pubkey", pubkey.as_hex_string())
|
||||||
.push_constant("kind", <EventKind as Into<u32>>::into(kind) as i64)
|
.push_constant("kind", <EventKind as Into<u32>>::into(kind) as i64)
|
||||||
.push_constant("content", content)
|
.push_constant("content", content)
|
||||||
|
.push_constant("tags", tags)
|
||||||
.push_constant(
|
.push_constant(
|
||||||
"nip05valid",
|
"nip05valid",
|
||||||
match &author {
|
match &author {
|
||||||
|
Loading…
Reference in New Issue
Block a user