🆙 Poll update

This commit is contained in:
Thomas 2023-02-28 09:35:24 +01:00
parent 01cdd98e92
commit 4b47572856

56
41.md
View File

@ -1,12 +1,27 @@
NIP-41 # NIP-41 - Poll & Vote Event
======
### Poll & Vote Event
-----------------------------------
`draft` `optional` `author:0xtlt` `draft` `optional` `author:0xtlt`
An event with kind `1` that wants to contain a poll can do so by adding poll tags and its content as follows: > Poll and vote events are a way to create a poll and vote for it.\
> Polls are directly integrated into message events (1), and responses are vote events (9) to avoid overloading the loading of messages in clients.
## Specs
### Kind `1` - Message & Poll
To create a poll, include a `poll` tag in the message event. with the following format:
```json
tag: poll
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
- [<option>]: array of string
```
And you can also add a `poll_name` tag to add a title to the poll, but it's optional.
#### Example - Message
```json ```json
{ {
@ -14,24 +29,29 @@ An event with kind `1` that wants to contain a poll can do so by adding poll tag
"kind": 1, "kind": 1,
"tags": [ "tags": [
... ...
["poll", "Choice 1"], ["poll", "Option 1", "Option 2", "Option 3"],
["poll", "Choice 2"], ["poll_name", "This is optional"]
["poll", "Choice 3"]
... ...
], ],
} }
``` ```
Then the client should display voting options if more than **1 choice** is present in the poll. ### Kind `9` - Vote
The client can then submit the vote by sending an event with kind `8` and its content which will be the index (start at `0`) of the chosen choice. To vote for a poll, you have to send an event kind `9`.\
The format of the event is the following:
It should also contain an `e` tag with the id of the poll event only. ```json
kind: 9
content: <choice, which is the index of the option | the first option is 0>
```
#### Example - Vote
```json ```json
{ {
... ...
"kind": 8, "kind": 9,
"tags": [ "tags": [
... ...
["e", "<event-id>"] ["e", "<event-id>"]
@ -41,6 +61,14 @@ It should also contain an `e` tag with the id of the poll event only.
} }
``` ```
#### Warning ## Relay and client recommendations
- Options should be limited to 4 options and should not display more than **4 options** in the poll
- Each option should be 25 chars limited
- Clients should display poll options if more than **one option** is present in the poll
- Clients should ignore vote events if the poll is **expired**
- Clients should not display more than one poll per message. The first poll in the message should be displayed.
## Warning
Keep in mind that all votes are public and accessible to everyone. Keep in mind that all votes are public and accessible to everyone.