message storage and from removed from packedusermessage (weakness)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2024-02-18 13:46:11 +01:00
parent 05cc2ee218
commit 07dfae8f0e
6 changed files with 138 additions and 117 deletions

View File

@ -35,17 +35,19 @@ type Peer struct {
InvitationUrl string `json:"invitation_url,omitempty"`
InvitationMessage string `json:"invitation_message,omitempty"`
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
LastMessage string `json:"last_message,omitempty"`
LastMessageDate int64 `json:"last_message_date,omitempty"`
LastMessageStatus string `json:"last_message_status,omitempty"`
// Internal management attributes
Visible bool `json:"visible,omitempty"`
VisiblePassword string `json:"visible_password,omitempty"`
PasswordType string `json:"password_type,omitempty"`
Blocked bool `json:"blocked,omitempty"`
MessageNotification string `json:"message_notification,omitempty"`
MatriochkaMode bool `json:"matriochka_mode,omitempty"`
DirectMode bool `json:"direct_mode,omitempty"`
LastMessage time.Time `json:"last_message,omitempty"`
DbIds []string `json:"db_ids,omitempty"`
IsDevice bool `json:"is_device,omitempty"`
Visible bool `json:"visible,omitempty"`
VisiblePassword string `json:"visible_password,omitempty"`
PasswordType string `json:"password_type,omitempty"`
Blocked bool `json:"blocked,omitempty"`
MessageNotification string `json:"message_notification,omitempty"`
MatriochkaMode bool `json:"matriochka_mode,omitempty"`
DirectMode bool `json:"direct_mode,omitempty"`
DbIds []string `json:"db_ids,omitempty"`
IsDevice bool `json:"is_device,omitempty"`
dbPassword string
}
@ -213,7 +215,6 @@ func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMe
// PackUserMessage will package the previously encrypted message
func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage {
var msg meowlib.PackedUserMessage
msg.From = p.MyIdentity.Public
msg.Destination = p.ContactLookupKey
msg.Payload = message
msg.Signature = signature
@ -287,12 +288,12 @@ func (p *Peer) UpdateMessage(msg InternalUserMessage) error {
return nil
}
func (p *Peer) LoadLastMessages(alreadyLoadedCount int, oldestMessageId int, qty int) ([]InternalUserMessage, error) {
func (p *Peer) LoadLastMessages(alreadyLoadedCount int, oldestMessageId int, qty int) ([]*InternalUserMessage, error) {
return GetMessagesHistory(p, alreadyLoadedCount, oldestMessageId, 1, p.GetDbPassword())
}
func (p *Peer) LoadNewMessages(lastMessageId int) ([]InternalUserMessage, error) {
func (p *Peer) LoadNewMessages(lastMessageId int) ([]*InternalUserMessage, error) {
return GetNewMessages(p, lastMessageId, p.GetDbPassword())
}