SetPollOptions remembers the plaintext options of a poll we just sent so that incoming votes (which arrive as SHA-256 hashes of the option text) can be resolved back to readable strings.
(userID, msgID string, options []string)
| 93 | // that incoming votes (which arrive as SHA-256 hashes of the option text) |
| 94 | // can be resolved back to readable strings. |
| 95 | func (cm *ClientManager) SetPollOptions(userID, msgID string, options []string) { |
| 96 | cm.Lock() |
| 97 | defer cm.Unlock() |
| 98 | if cm.pollOptions[userID] == nil { |
| 99 | cm.pollOptions[userID] = make(map[string][]string) |
| 100 | } |
| 101 | stored := make([]string, len(options)) |
| 102 | copy(stored, options) |
| 103 | cm.pollOptions[userID][msgID] = stored |
| 104 | } |
| 105 | |
| 106 | // GetPollOptions returns the plaintext options associated with a poll |
| 107 | // message, or nil if none were recorded (e.g. wuzapi restarted after the |