Browse Source

Merge branch 'storagebugfix' of cwtch.im/cwtch into master

pull/206/head
Dan Ballard Gogs 1 year ago
parent
commit
f52144a67c
3 changed files with 3 additions and 5 deletions
  1. +1
    -0
      event/common.go
  2. +1
    -2
      peer/cwtch_peer.go
  3. +1
    -3
      storage/profile_store.go

+ 1
- 0
event/common.go View File

@@ -71,6 +71,7 @@ const (
RemotePeer = Field("RemotePeer")
Ciphertext = Field("Ciphertext")
Signature = Field("Signature")
PreviousSignature = Field("PreviousSignature")
TimestampSent = Field("TimestampSent")
TimestampReceived = Field("TimestampReceived")



+ 1
- 2
peer/cwtch_peer.go View File

@@ -313,9 +313,8 @@ func (cp *cwtchPeer) eventHandler() {
switch ev.EventType {
case event.EncryptedGroupMessage:
ok, groupID, message, seen := cp.Profile.AttemptDecryption([]byte(ev.Data[event.Ciphertext]), []byte(ev.Data[event.Signature]))
log.Debugf("ok,gid,msg = %v,%v,%v", ok, groupID, message)
if ok && !seen {
cp.eventBus.Publish(event.NewEvent(event.NewMessageFromGroup, map[event.Field]string{event.TimestampReceived: message.Received.Format(time.RFC3339Nano), event.TimestampSent: message.Timestamp.Format(time.RFC3339Nano), event.Data: message.Message, event.GroupID: groupID, event.Signature: string(message.Signature), event.RemotePeer: message.PeerID}))
cp.eventBus.Publish(event.NewEvent(event.NewMessageFromGroup, map[event.Field]string{event.TimestampReceived: message.Received.Format(time.RFC3339Nano), event.TimestampSent: message.Timestamp.Format(time.RFC3339Nano), event.Data: message.Message, event.GroupID: groupID, event.Signature: string(message.Signature), event.PreviousSignature: string(message.PreviousMessageSig), event.RemotePeer: message.PeerID}))
}
case event.NewGroupInvite:
var groupInvite protocol.GroupChatInvite


+ 1
- 3
storage/profile_store.go View File

@@ -152,9 +152,7 @@ func (ps *profileStore) eventHandler() {
groupid := ev.Data[event.GroupID]
received, _ := time.Parse(time.RFC3339Nano, ev.Data[event.TimestampReceived])
sent, _ := time.Parse(time.RFC3339Nano, ev.Data[event.TimestampSent])
// TODO: Sig, prev message Sig
message := model.Message{Received: received, Timestamp: sent, Message: ev.Data[event.Data], PeerID: ev.Data[event.RemotePeer], Signature: []byte(ev.Data[event.Signature])}
//ps.profile.Groups[groupid].AddMessage(message) <- wants protocol.DecryptedGroupMessage so group.Timeline will drift here from launch when it's initialized
message := model.Message{Received: received, Timestamp: sent, Message: ev.Data[event.Data], PeerID: ev.Data[event.RemotePeer], Signature: []byte(ev.Data[event.Signature]), PreviousMessageSig:[]byte(ev.Data[event.PreviousSignature])}
ps.streamStores[groupid].Write(message)
default:
return


Loading…
Cancel
Save