From 509e5c95ba02bf5882f31cfa8963a833fac6f3af Mon Sep 17 00:00:00 2001 From: erinn Date: Sat, 3 Oct 2020 16:09:47 -0700 Subject: [PATCH] expose cwtchPeer.Profile.AddMessageToContactTimeline() via StoreMessage() --- peer/cwtch_peer.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index f56e096..bcbf1fa 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -50,6 +50,7 @@ type CwtchPeer interface { InviteOnionToGroup(string, string) error SendMessageToPeer(string, string) string SendGetValToPeer(string, string, string) + StoreMessage(onion string, messageTxt string, sent time.Time) SetContactAuthorization(string, model.Authorization) error ProcessInvite(string, string) (string, error) @@ -566,6 +567,12 @@ func (cp *cwtchPeer) Shutdown() { cp.queue.Shutdown() } +func (cp *cwtchPeer) StoreMessage(onion string, messageTxt string, sent time.Time) { + cp.mutex.Lock() + cp.Profile.AddMessageToContactTimeline(onion, messageTxt, sent) + cp.mutex.Unlock() +} + // eventHandler process events from other subsystems func (cp *cwtchPeer) eventHandler() { for { @@ -583,10 +590,7 @@ func (cp *cwtchPeer) eventHandler() { } case event.NewMessageFromPeer: //event.TimestampReceived, event.RemotePeer, event.Data - ts, _ := time.Parse(time.RFC3339Nano, ev.Data[event.TimestampReceived]) - cp.mutex.Lock() - cp.Profile.AddMessageToContactTimeline(ev.Data[event.RemotePeer], ev.Data[event.Data], ts) - cp.mutex.Unlock() + cp.StoreMessage(ev.Data[event.RemotePeer], ev.Data[event.Data], ts) case event.PeerAcknowledgement: cp.mutex.Lock()