forked from cwtch.im/cwtch
expose cwtchPeer.Profile.AddMessageToContactTimeline() via StoreMessage()
This commit is contained in:
parent
4606489cca
commit
b423f1e176
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue