expose cwtchPeer.Profile.AddMessageToContactTimeline() via StoreMessage()

This commit is contained in:
erinn 2020-10-03 16:09:47 -07:00
parent 5772ce45a4
commit 509e5c95ba
1 changed files with 8 additions and 4 deletions

View File

@ -50,6 +50,7 @@ type CwtchPeer interface {
InviteOnionToGroup(string, string) error InviteOnionToGroup(string, string) error
SendMessageToPeer(string, string) string SendMessageToPeer(string, string) string
SendGetValToPeer(string, string, string) SendGetValToPeer(string, string, string)
StoreMessage(onion string, messageTxt string, sent time.Time)
SetContactAuthorization(string, model.Authorization) error SetContactAuthorization(string, model.Authorization) error
ProcessInvite(string, string) (string, error) ProcessInvite(string, string) (string, error)
@ -566,6 +567,12 @@ func (cp *cwtchPeer) Shutdown() {
cp.queue.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 // eventHandler process events from other subsystems
func (cp *cwtchPeer) eventHandler() { func (cp *cwtchPeer) eventHandler() {
for { for {
@ -583,10 +590,7 @@ func (cp *cwtchPeer) eventHandler() {
} }
case event.NewMessageFromPeer: //event.TimestampReceived, event.RemotePeer, event.Data case event.NewMessageFromPeer: //event.TimestampReceived, event.RemotePeer, event.Data
ts, _ := time.Parse(time.RFC3339Nano, ev.Data[event.TimestampReceived]) cp.StoreMessage(ev.Data[event.RemotePeer], ev.Data[event.Data], ts)
cp.mutex.Lock()
cp.Profile.AddMessageToContactTimeline(ev.Data[event.RemotePeer], ev.Data[event.Data], ts)
cp.mutex.Unlock()
case event.PeerAcknowledgement: case event.PeerAcknowledgement:
cp.mutex.Lock() cp.mutex.Lock()