feat: add surveys / polls

This commit is contained in:
Fernando López Guevara 2022-12-22 12:31:49 -03:00
parent 745297e8c4
commit 64bb88c83d
2 changed files with 70 additions and 0 deletions

View File

@ -27,6 +27,7 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh
- [NIP-35: User Discovery](35.md) - [NIP-35: User Discovery](35.md)
- [NIP-36: Sensitive Content](36.md) - [NIP-36: Sensitive Content](36.md)
- [NIP-40: Expiration Timestamp](40.md) - [NIP-40: Expiration Timestamp](40.md)
- [NIP-XX: Surveys/Polls](XX.md)
## Event Kinds ## Event Kinds

69
XX.md Normal file
View File

@ -0,0 +1,69 @@
NIP-XX
======
Surveys / polls
-----------------------------------
`draft` `optional` `require:nip-20` `author:fernandolguevara`
The `surv` & `surv-resp` tags enables users to have surveys/polls experiences on the network.
#### Spec
##### Message
```
tag: surv
options:
- <multi|single> allow others to reply with one or multiple options
- <ttl> TTL (in seconds|timestamp) when surv expires, 0 TTL don't expire
- [<choice>]: up to 4 choices each limited to 25 chars
````
```
tag: surv-resp
options:
- [<choice>]: based on surv type it can have one or multi
````
##### Relays
One vote per key, relays needs to discard all subsequent votes, as well as invalid requests.
##### Invalid responses
```json
["OK", <event_id>, false, 'ALREADY_ANSWERED'],
["OK", <event_id>, false, 'EXPIRED'],
["OK", <event_id>, false, 'SINGLE_OPTION'],
["OK", <event_id>, false, 'INVALID_OPTION', 'optionX', ...],
```
#### Example
```json
{
"pubkey": "<pub-key>",
"created_at": 1000000000,
"kind": 1,
"tags": [
["t", "hastag"],
["surv", "<multi|single>", "<ttl>", "option 1", "option 2", "option 3"]
],
"content": "#hastag what is your favorite option?",
"id": "<event-id>"
},
{
"pubkey": "<pub-key>",
"created_at": 1000000000,
"kind": 1,
"tags": [
["p", "<pub-key-root>", "wss://..."],
["e", "<event-id-root>", "wss://...", "root"],
["t", "tag"],
["surv-resp", "option 1", "option 2"...] // based on root event surv type it can have one or multi
],
"content": "hello #tag\n",
"id": "<event-id>"
}
```