Add client support for NIP-02 (manage contact lists)
This commit is contained in:
parent
e6e4f576e3
commit
19f07efdeb
30
README.md
30
README.md
@ -192,10 +192,38 @@ event = user.create_event(
|
|||||||
client.publish(event)
|
client.publish(event)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Creating/updating your contact list
|
||||||
|
|
||||||
|
Every new contact list that gets published overwrites the past ones, so it should contain all entries.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
# Creating a contact list event with 2 contacts
|
||||||
|
update_contacts_event = user.create_event(
|
||||||
|
kind: Nostr::EventKind::CONTACT_LIST,
|
||||||
|
tags: [
|
||||||
|
[
|
||||||
|
"p", # mandatory
|
||||||
|
"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245", # public key of the user to add to the contacts
|
||||||
|
"wss://alicerelay.com/", # can be an empty string or can be omitted
|
||||||
|
"alice" # can be an empty string or can be omitted
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"p", # mandatory
|
||||||
|
"3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681", # public key of the user to add to the contacts
|
||||||
|
"wss://bobrelay.com/nostr", # can be an empty string or can be omitted
|
||||||
|
"bob" # can be an empty string or can be omitted
|
||||||
|
],
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Send it to the Relay
|
||||||
|
client.publish(update_contacts_event)
|
||||||
|
```
|
||||||
|
|
||||||
## NIPS
|
## NIPS
|
||||||
|
|
||||||
- [x] [NIP-01 - Client](https://github.com/nostr-protocol/nips/blob/master/01.md)
|
- [x] [NIP-01 - Client](https://github.com/nostr-protocol/nips/blob/master/01.md)
|
||||||
- [ ] [NIP-01 - Relay](https://github.com/nostr-protocol/nips/blob/master/01.md)
|
- [x] [NIP-02 - Client](https://github.com/nostr-protocol/nips/blob/master/02.md)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ module Nostr
|
|||||||
#
|
#
|
||||||
attr_reader :created_at
|
attr_reader :created_at
|
||||||
|
|
||||||
# The kind of the event. An integer from 0 to 2
|
# The kind of the event. An integer from 0 to 3
|
||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
#
|
#
|
||||||
@ -76,7 +76,7 @@ module Nostr
|
|||||||
#
|
#
|
||||||
# @param pubkey [String] 32-bytes hex-encoded public key of the event creator.
|
# @param pubkey [String] 32-bytes hex-encoded public key of the event creator.
|
||||||
# @param created_at [Integer] Date of the creation of the vent. A UNIX timestamp, in seconds.
|
# @param created_at [Integer] Date of the creation of the vent. A UNIX timestamp, in seconds.
|
||||||
# @param kind [Integer] The kind of the event. An integer from 0 to 2.
|
# @param kind [Integer] The kind of the event. An integer from 0 to 3.
|
||||||
# @param tags [Array<Array>] An array of tags. Each tag is an array of strings.
|
# @param tags [Array<Array>] An array of tags. Each tag is an array of strings.
|
||||||
# @param content [String] Arbitrary string.
|
# @param content [String] Arbitrary string.
|
||||||
#
|
#
|
||||||
|
@ -24,5 +24,12 @@ module Nostr
|
|||||||
# @return [Integer]
|
# @return [Integer]
|
||||||
#
|
#
|
||||||
RECOMMEND_SERVER = 2
|
RECOMMEND_SERVER = 2
|
||||||
|
|
||||||
|
# A special event with kind 3, meaning "contact list" is defined as having a list of p tags, one for each of
|
||||||
|
# the followed/known profiles one is following.
|
||||||
|
#
|
||||||
|
# @return [Integer]
|
||||||
|
#
|
||||||
|
CONTACT_LIST = 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ module Nostr
|
|||||||
# @param event_attributes [Hash]
|
# @param event_attributes [Hash]
|
||||||
# @option event_attributes [String] :pubkey 32-bytes hex-encoded public key of the event creator.
|
# @option event_attributes [String] :pubkey 32-bytes hex-encoded public key of the event creator.
|
||||||
# @option event_attributes [Integer] :created_at Date of the creation of the vent. A UNIX timestamp, in seconds.
|
# @option event_attributes [Integer] :created_at Date of the creation of the vent. A UNIX timestamp, in seconds.
|
||||||
# @option event_attributes [Integer] :kind The kind of the event. An integer from 0 to 2.
|
# @option event_attributes [Integer] :kind The kind of the event. An integer from 0 to 3.
|
||||||
# @option event_attributes [Array<Array>] :tags An array of tags. Each tag is an array of strings.
|
# @option event_attributes [Array<Array>] :tags An array of tags. Each tag is an array of strings.
|
||||||
# @option event_attributes [String] :content Arbitrary string.
|
# @option event_attributes [String] :content Arbitrary string.
|
||||||
#
|
#
|
||||||
|
@ -3,6 +3,6 @@ module Nostr
|
|||||||
SET_METADATA: Integer
|
SET_METADATA: Integer
|
||||||
TEXT_NOTE: Integer
|
TEXT_NOTE: Integer
|
||||||
RECOMMEND_SERVER: Integer
|
RECOMMEND_SERVER: Integer
|
||||||
CONTACTS: Integer
|
CONTACT_LIST: Integer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user