From dfb4f7c14e7d6aa7e1598a2834149d7e02920e39 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 18 Nov 2021 23:55:16 -0800 Subject: [PATCH] Sent new message total for Group Messages --- peer/cwtch_peer.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index 6f21f45..2e8d21f 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -771,7 +771,14 @@ const groupPrefix = "torv3" const importBundlePrefix = "importBundle" func (cp *cwtchPeer) ImportBundle(importString string) error { - if strings.HasPrefix(importString, tofuBundlePrefix) { + if tor.IsValidHostname(importString) { + _,err := cp.NewContactConversation(importString, model.DefaultP2PAccessControl(), true) + if err == nil { + return ConstructResponse(importBundlePrefix, "success") + } else { + return ConstructResponse(importBundlePrefix, err.Error()) + } + } else if strings.HasPrefix(importString, tofuBundlePrefix) { bundle := strings.Split(importString, "||") if len(bundle) == 2 { err := cp.ImportBundle(bundle[0][len(tofuBundlePrefix):]) @@ -1148,8 +1155,9 @@ func (cp *cwtchPeer) attemptInsertOrAcknowledgeLegacyGroupConversation(conversat } else { cp.mutex.Lock() cp.storage.InsertMessage(conversationID, 0, dm.Text, model.Attributes{constants.AttrAck: constants.True, "PreviousSignature": base64.StdEncoding.EncodeToString(dm.PreviousMessageSig), constants.AttrAuthor: dm.Onion, constants.AttrSentTimestamp: time.Unix(int64(dm.Timestamp), 0).Format(time.RFC3339Nano)}, signature, model.CalculateContentHash(dm.Onion, dm.Text)) + newTotal,_ := cp.storage.GetChannelMessageCount(conversationID, 0) cp.mutex.Unlock() - cp.eventBus.Publish(event.NewEvent(event.NewMessageFromGroup, map[event.Field]string{event.ConversationID: strconv.Itoa(conversationID), event.RemotePeer: dm.Onion, event.Index: strconv.Itoa(messageID)})) + cp.eventBus.Publish(event.NewEvent(event.NewMessageFromGroup, map[event.Field]string{event.ConversationID: strconv.Itoa(conversationID), event.TimestampSent: time.Unix(int64(dm.Timestamp), 0).Format(time.RFC3339Nano), event.RemotePeer: dm.Onion, event.Index: strconv.Itoa(newTotal)})) return nil } return err