Show the event kind with the payload and name more kinds
The kind was collapsed under Details, but it is part of what is being signed, so it now sits with the payload — right after Application, before the content and tags. Details keeps the client key and declared URL. kind::name covered only nine kinds, so a relay list (10002) read as "event". Fill it out with the well-known kinds (the NIP-51 lists, NIP-17/59 messaging, NIP-28 channels, zaps, labels, calendar, community, …), keeping the names short and lowercase. Unknown kinds still read "event".
This commit is contained in:
2 files changed
+100
-9
No files matched your search
+9
-6
@@ -450,6 +450,14 @@ fn details(
|
||||
"Application",
|
||||
client.name.as_deref().unwrap_or("(unnamed)"),
|
||||
));
|
||||
// The kind is part of what is being signed, so it sits with the payload
|
||||
// rather than collapsed under Details.
|
||||
if let Request::Sign { kind, .. } = &question.request {
|
||||
content.append(&plain::text_field(
|
||||
"Kind",
|
||||
&format!("{} ({})", kind, kind::name(*kind)),
|
||||
));
|
||||
}
|
||||
|
||||
match &question.request {
|
||||
Request::Pair { .. } => {}
|
||||
@@ -516,12 +524,7 @@ fn more_details(question: &Question) -> gtk::ListBox {
|
||||
row.add_row(&plain::row("Asked for", requested));
|
||||
}
|
||||
}
|
||||
Request::Sign { kind, .. } => {
|
||||
row.add_row(&plain::row(
|
||||
"Kind",
|
||||
&format!("{} ({})", kind, kind::name(*kind)),
|
||||
));
|
||||
}
|
||||
Request::Sign { .. } => {}
|
||||
Request::Encrypt { method, peer, .. } | Request::Decrypt { method, peer, .. } => {
|
||||
row.add_row(&plain::row("Method", method));
|
||||
let peer_row = plain::row("Peer", &plain::shorten_npub(peer));
|
||||
|
||||
+91
-3
@@ -1,18 +1,96 @@
|
||||
//! Human names for the common event kinds, shared by the dialogs and the
|
||||
//! permission table.
|
||||
|
||||
/// A short, human name for the common kinds; a generic one otherwise.
|
||||
/// A short, human name for the well-known kinds; a generic one otherwise.
|
||||
///
|
||||
/// Names stay lowercase and concise to read as a value (`10002 (relay list)`),
|
||||
/// and cover the kinds a signer is actually asked for. Anything unknown is just
|
||||
/// "event".
|
||||
pub fn name(kind: u16) -> &'static str {
|
||||
match kind {
|
||||
// Notes and social (NIP-01, 10, 18, 25, 68, 71, 7D).
|
||||
0 => "profile metadata",
|
||||
1 => "text note",
|
||||
2 => "relay recommendation",
|
||||
3 => "follow list",
|
||||
4 => "encrypted direct message",
|
||||
5 => "deletion",
|
||||
5 => "deletion request",
|
||||
6 => "repost",
|
||||
7 => "reaction",
|
||||
24133 => "NIP-46 message",
|
||||
8 => "badge award",
|
||||
9 => "chat message",
|
||||
11 => "thread",
|
||||
16 => "generic repost",
|
||||
17 => "website reaction",
|
||||
20 => "picture",
|
||||
21 => "video",
|
||||
22 => "short video",
|
||||
// Private messaging and wrapping (NIP-17, 59).
|
||||
13 => "seal",
|
||||
14 => "direct message",
|
||||
15 => "file message",
|
||||
1059 => "gift wrap",
|
||||
1222 => "voice message",
|
||||
// Channels (NIP-28).
|
||||
40 => "channel creation",
|
||||
41 => "channel metadata",
|
||||
42 => "channel message",
|
||||
43 => "channel hide message",
|
||||
44 => "channel mute user",
|
||||
// Replaceable lists (NIP-51).
|
||||
10000 => "mute list",
|
||||
10001 => "pin list",
|
||||
10002 => "relay list",
|
||||
10003 => "bookmark list",
|
||||
10004 => "communities list",
|
||||
10005 => "public chats list",
|
||||
10006 => "blocked relays list",
|
||||
10007 => "search relays list",
|
||||
10008 => "profile badges",
|
||||
10009 => "user groups",
|
||||
10011 => "external identities",
|
||||
10012 => "favorite relays list",
|
||||
10013 => "private event relay list",
|
||||
10015 => "interests list",
|
||||
10030 => "emoji list",
|
||||
10050 => "direct message relay list",
|
||||
// Files, labels, reporting, zaps (NIP-32, 56, 57, 84, 94).
|
||||
1063 => "file metadata",
|
||||
1984 => "report",
|
||||
1985 => "label",
|
||||
9734 => "zap request",
|
||||
9735 => "zap",
|
||||
9802 => "highlight",
|
||||
// Other common kinds.
|
||||
62 => "request to vanish",
|
||||
78 | 30078 => "application data",
|
||||
1068 => "poll",
|
||||
1111 => "comment",
|
||||
1311 => "live chat message",
|
||||
1337 => "code snippet",
|
||||
1617 => "patch",
|
||||
1618 => "pull request",
|
||||
1621 => "issue",
|
||||
1630..=1633 => "status",
|
||||
22242 => "client authentication",
|
||||
23194 => "wallet request",
|
||||
23195 => "wallet response",
|
||||
27235 => "HTTP auth",
|
||||
30000 => "follow sets",
|
||||
30003 => "bookmark sets",
|
||||
30023 => "long-form article",
|
||||
30024 => "draft article",
|
||||
30311 => "live event",
|
||||
30315 => "user status",
|
||||
30402 => "classified listing",
|
||||
30617 => "repository announcement",
|
||||
30818 => "wiki article",
|
||||
31922 => "calendar event (date)",
|
||||
31923 => "calendar event (time)",
|
||||
31924 => "calendar",
|
||||
31925 => "calendar RSVP",
|
||||
34550 => "community definition",
|
||||
24133 => "NIP-46 message",
|
||||
_ => "event",
|
||||
}
|
||||
}
|
||||
@@ -97,4 +175,14 @@ mod tests {
|
||||
assert_eq!(field_group("about"), Some("About"));
|
||||
assert_eq!(field_group("something_odd"), None);
|
||||
}
|
||||
|
||||
/// Well-known kinds get a name; anything unknown stays "event".
|
||||
#[test]
|
||||
fn well_known_kinds_are_named() {
|
||||
assert_eq!(name(1), "text note");
|
||||
assert_eq!(name(10002), "relay list");
|
||||
assert_eq!(name(30023), "long-form article");
|
||||
assert_eq!(name(1631), "status");
|
||||
assert_eq!(name(65535), "event");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user