vicariousdrama / cornychat

🌽 Corny Chat is an open source audio space built on Jam that integrates Nostr and Lightning
https://cornychat.com
GNU Affero General Public License v3.0
19 stars 6 forks source link

User Labels/Petnames #44

Closed vicariousdrama closed 2 months ago

vicariousdrama commented 5 months ago

Add support to Corny Chat to load all pet names authored by the user (filter: {authors: [userpubkey], kind: [1985,30382]}) and cache in the session storage.

Reference the session storage of these labels when rendering the names of the following places

Allow a user of Corny Chat to assign a label by viewing the profile of a user and inputting a petname.


NIP-32: Labeling https://github.com/nostr-protocol/nips/blob/master/32.md

If using NIP-32, its kind 1985. The namespace L used is com.cornychat. The label l can be petname with the content field reflecting the petname given

Note that NIP-32 ends with this

A good heuristic for whether a use case fits this NIP is whether labels would ever be unique. For example, many events might be labeled with a particular place, topic, or pubkey, but labels with specific values like "John Doe" or "3.18743" are not labels, they are values, and should be handled in some other way.

Another weakness is that these are long lived, non-temporal labels.


Alternative NIP-81: Relationship Status https://github.com/vitorpamplona/nips/blob/relationship-status/81.md

This approach uses a replaceable kind 30382, where the d tag is the targeted pubkey being associated, and n tags for theoretical lists. A petname can be used for assigning the label that the user should see in place of the target's self identified name per kind0. The following example optionally encrypts the petname and a summary tag, both of which can be plaintext tags

{
  "kind": 30382,
  "tags": [
    ["d", "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411"],
    ["n", "Follows"],
    ["n", "Bitcoiners"],
    ["n", "6064460175057025"]
  ],
  "content": nip44Encrypt(JSON.stringify([
    ["petname", "NVK (Coldcard)"],
    ["summary", "Owes me a beer"]
  ])),
  // ...other fields
}

As a replaceable, special care must be taken when creating and editing the petname of a user to check for existing definitions, and ONLY update the relevant field (e.g. the petname) while keeping the lists (n tags) and others intact.

vicariousdrama commented 2 months ago

Completed using NIP-81 https://github.com/nostr-protocol/nips/pull/761 https://github.com/vitorpamplona/nips/blob/relationship-status/81.md