From f40f6520d285ed050ed130d081036147e46ff43e Mon Sep 17 00:00:00 2001 From: ycc Date: Tue, 5 Mar 2024 20:15:48 +0100 Subject: [PATCH] add last message to peers --- client/messagestorage.go | 9 ++++++++- client/peer.go | 20 +++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/client/messagestorage.go b/client/messagestorage.go index 87c5e35..41ee534 100644 --- a/client/messagestorage.go +++ b/client/messagestorage.go @@ -73,10 +73,17 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri if err != nil { return err } - _, err = statement.Exec(encData) + result, err := statement.Exec(encData) if err != nil { return err } + id, err := result.LastInsertId() + if err != nil { + return err + } + ium := DbMessageToInternalUserMessage(id, dbid, dbm) + peer.LastMessage = ium + GetConfig().me.Save() return nil } diff --git a/client/peer.go b/client/peer.go index 2cae9e6..83524e8 100644 --- a/client/peer.go +++ b/client/peer.go @@ -27,17 +27,15 @@ type Peer struct { MyPullServers []string `json:"my_pull_servers,omitempty"` // Peer keys and infos //Contact meowlib.ContactCard `json:"contact,omitempty"` // todo : remove - ContactPublicKey string `json:"contact_public_key,omitempty"` - ContactLookupKey string `json:"contact_lookup_key,omitempty"` - ContactEncryption string `json:"contact_encryption,omitempty"` - ContactPullServers []string `json:"contact_pull_servers,omitempty"` - InvitationId string `json:"invitation_id,omitempty"` - 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"` + ContactPublicKey string `json:"contact_public_key,omitempty"` + ContactLookupKey string `json:"contact_lookup_key,omitempty"` + ContactEncryption string `json:"contact_encryption,omitempty"` + ContactPullServers []string `json:"contact_pull_servers,omitempty"` + InvitationId string `json:"invitation_id,omitempty"` + InvitationUrl string `json:"invitation_url,omitempty"` + InvitationMessage string `json:"invitation_message,omitempty"` + InvitationExpiry time.Time `json:"invitation_expiry,omitempty"` + LastMessage *InternalUserMessage `json:"last_message,omitempty"` // Internal management attributes Visible bool `json:"visible,omitempty"` VisiblePassword string `json:"visible_password,omitempty"`