Skip to content

Commit

Permalink
nostrdb/tce: add AUTH to-client-event
Browse files Browse the repository at this point in the history
This was committed to damus, but this should be in nostrdb or else we
will lose it when we update.

Damus: 84cfeb1 ("nip42: add initial relay auth support")
Link: https://groups.google.com/a/damus.io/g/patches/c/Zx3dk01e0yg/m/t59TsVkXAQAJ
Signed-off-by: Charlie Fish <contact@charlie.fish>
Signed-off-by: William Casarin <jb55@jb55.com>
  • Loading branch information
fishcharlie authored and jb55 committed Jan 25, 2024
1 parent 3e50bfb commit 34093cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nostrdb/src/nostrdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4952,6 +4952,17 @@ int ndb_ws_event_from_json(const char *json, int len, struct ndb_tce *tce,
tce->command_result.msg = json + tok->start;
tce->command_result.msglen = toksize(tok);

return 1;
} else if (tok_len == 4 && !memcmp("AUTH", json + tok->start, 4)) {
tce->evtype = NDB_TCE_AUTH;

tok = &parser.toks[parser.i++];
if (tok->type != JSMN_STRING)
return 0;

tce->subid = json + tok->start;
tce->subid_len = toksize(tok);

return 1;
}

Expand Down
1 change: 1 addition & 0 deletions nostrdb/src/nostrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum tce_type {
NDB_TCE_OK = 0x2,
NDB_TCE_NOTICE = 0x3,
NDB_TCE_EOSE = 0x4,
NDB_TCE_AUTH = 0x5,
};

enum ndb_ingest_filter_action {
Expand Down

0 comments on commit 34093cd

Please sign in to comment.