mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-21 16:59:06 -05:00
feat(NIP-42): extend authz to NIP-44 DMs and NIP-59 gift wraps
This commit is contained in:
parent
23aa6e7313
commit
b1957ab2b1
|
@ -160,7 +160,7 @@ reject_future_seconds = 1800
|
|||
#]
|
||||
# Enable NIP-42 authentication
|
||||
#nip42_auth = false
|
||||
# Send DMs events (kind 4) only to their authenticated recipients
|
||||
# Send DMs (kind 4 and 44) and gift wraps (kind 1059) only to their authenticated recipients
|
||||
#nip42_dms = false
|
||||
|
||||
[verified_users]
|
||||
|
|
|
@ -63,7 +63,7 @@ pub struct RelayInfo {
|
|||
/// Convert an Info configuration into public Relay Info
|
||||
impl From<Settings> for RelayInfo {
|
||||
fn from(c: Settings) -> Self {
|
||||
let mut supported_nips = vec![1, 2, 9, 11, 12, 15, 16, 20, 22, 33, 40, 42];
|
||||
let mut supported_nips = vec![1, 2, 9, 11, 12, 15, 16, 20, 22, 33, 40];
|
||||
|
||||
if c.authorization.nip42_auth {
|
||||
supported_nips.push(42);
|
||||
|
|
|
@ -1034,7 +1034,7 @@ fn allowed_to_send(event_str: &String, conn: &conn::ClientConn, settings: &Setti
|
|||
if settings.authorization.nip42_dms {
|
||||
match serde_json::from_str::<Event>(event_str) {
|
||||
Ok(event) => {
|
||||
if event.kind == 4 {
|
||||
if event.kind == 4 || event.kind == 44 || event.kind == 1059 {
|
||||
match (conn.auth_pubkey(), event.tag_values_by_name("p").first()) {
|
||||
(Some(auth_pubkey), Some(recipient_pubkey)) => {
|
||||
recipient_pubkey == auth_pubkey || &event.pubkey == auth_pubkey
|
||||
|
|
Loading…
Reference in New Issue
Block a user