Continued

This commit is contained in:
Philipp Heckel 2022-07-13 20:31:17 -04:00
parent 78f9d4835e
commit cae06c5c61
7 changed files with 78 additions and 15 deletions

View file

@ -33,7 +33,7 @@ type message struct {
Attachment *attachment `json:"attachment,omitempty"`
PollID string `json:"poll_id,omitempty"`
Sender string `json:"-"` // IP address of uploader, used for rate limiting
Encoding string `json:"encoding,omitempty"` // empty for raw UTF-8, or "base64" for encoded bytes
Encoding string `json:"encoding,omitempty"` // empty for UTF-8, "base64", or "jwe" (encrypted)
}
type attachment struct {
@ -115,6 +115,12 @@ func newPollRequestMessage(topic, pollID string) *message {
return m
}
func newEncryptedMessage(topic, msg string) *message {
m := newMessage(messageEvent, topic, msg)
m.Encoding = encodingJWE
return m
}
func validMessageID(s string) bool {
return util.ValidRandomString(s, messageIDLength)
}