-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PinMessage and PinnedMessage (#2180)
* add PinMessage and PinnedMessage * fix gruop pin messages * add SkipGroupMessageWrap to pin messages * update pinMessage ID generation to be symmetric
- Loading branch information
1 parent
6a930ed
commit e9a42bf
Showing
18 changed files
with
1,078 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package common | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
|
||
"github.com/golang/protobuf/proto" | ||
|
||
"github.com/status-im/status-go/protocol/protobuf" | ||
) | ||
|
||
type PinMessage struct { | ||
protobuf.PinMessage | ||
|
||
// ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload. | ||
ID string `json:"id"` | ||
// MessageID string `json:"messageID"` | ||
// WhisperTimestamp is a timestamp of a Whisper envelope. | ||
WhisperTimestamp uint64 `json:"whisperTimestamp"` | ||
// From is a public key of the user who pinned the message. | ||
From string `json:"from"` | ||
// The chat id to be stored locally | ||
LocalChatID string `json:"localChatId"` | ||
SigPubKey *ecdsa.PublicKey `json:"-"` | ||
// Identicon of the author | ||
Identicon string `json:"identicon"` | ||
// Random 3 words name | ||
Alias string `json:"alias"` | ||
} | ||
|
||
type PinnedMessage struct { | ||
Message | ||
PinnedAt uint64 `json:"pinnedAt"` | ||
} | ||
|
||
// WrapGroupMessage indicates whether we should wrap this in membership information | ||
func (m *PinMessage) WrapGroupMessage() bool { | ||
return false | ||
} | ||
|
||
// SetMessageType a setter for the MessageType field | ||
// this function is required to implement the ChatEntity interface | ||
func (m *PinMessage) SetMessageType(messageType protobuf.MessageType) { | ||
m.MessageType = messageType | ||
} | ||
|
||
func (m *PinMessage) GetGrant() []byte { | ||
return nil | ||
} | ||
|
||
// GetProtoBuf returns the struct's embedded protobuf struct | ||
// this function is required to implement the ChatEntity interface | ||
func (m *PinMessage) GetProtobuf() proto.Message { | ||
return &m.PinMessage | ||
} | ||
|
||
// GetSigPubKey returns an ecdsa encoded public key | ||
// this function is required to implement the ChatEntity interface | ||
func (m PinMessage) GetSigPubKey() *ecdsa.PublicKey { | ||
return m.SigPubKey | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.