From 82a801678b1534f6bd1c695a14d0769b3a7c42cd Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 20 Jan 2022 12:37:39 -0500 Subject: [PATCH] add more ContentHash to get*Message* functions, upgrade cwtch for the same --- go.mod | 2 +- go.sum | 2 ++ lib.go | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 62c3a52..dd10cee 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go go 1.15 require ( - cwtch.im/cwtch v0.14.12 + cwtch.im/cwtch v0.14.13 git.openprivacy.ca/cwtch.im/server v1.4.2 git.openprivacy.ca/openprivacy/connectivity v1.8.1 git.openprivacy.ca/openprivacy/log v1.0.3 diff --git a/go.sum b/go.sum index 4ebcbb3..7c210f1 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cwtch.im/cwtch v0.14.9/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= cwtch.im/cwtch v0.14.12 h1:dAYmhm5eb3Bi6yPG3qhFpTp7LLRdJvwRQPBCcdUtkbY= cwtch.im/cwtch v0.14.12/go.mod h1:zFDii7KgKt1tTN1fwuHUiIpjjyoUK+B7qcdCYOkfJbk= +cwtch.im/cwtch v0.14.13 h1:YfKsHiAQ2JnDsl7CwtGGTratu22lGC0hlp23jBNGIVs= +cwtch.im/cwtch v0.14.13/go.mod h1:zFDii7KgKt1tTN1fwuHUiIpjjyoUK+B7qcdCYOkfJbk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= diff --git a/lib.go b/lib.go index 6258f44..74641f8 100644 --- a/lib.go +++ b/lib.go @@ -573,6 +573,7 @@ type EnhancedMessage struct { model.Message ID int // the actual ID of the message in the database (not the row number) LocalIndex int // local index in the DB (row #). Can be empty (most calls supply it) but lookup by hash will fill it + ContentHash string ContactImage string Attributes map[string]string } @@ -599,6 +600,7 @@ func GetMessage(profileOnion string, conversationID int, messageIndex int) strin message.ID = messages[0].ID message.Attributes = messages[0].Attr message.ContactImage = utils.RandomProfileImage(message.PeerID) + message.ContentHash = model.CalculateContentHash(messages[0].Attr[constants2.AttrAuthor], messages[0].Body) } } bytes, _ := json.Marshal(message) @@ -634,6 +636,7 @@ func GetMessageByID(profileOnion string, conversationID int, messageID int) stri message.ID = messageID message.Attributes = attr message.ContactImage = utils.RandomProfileImage(message.PeerID) + message.ContentHash = model.CalculateContentHash(attr[constants2.AttrAuthor], dbmessage) } } bytes, _ := json.Marshal(message) @@ -668,6 +671,7 @@ func GetMessagesByContentHash(profileOnion string, handle int, contentHash strin message.Attributes = messages[0].Attr message.ContactImage = utils.RandomProfileImage(message.PeerID) message.LocalIndex = offset + message.ContentHash = contentHash } else { log.Errorf("error fetching local index {} ", err) }