add more ContentHash to get*Message* functions, upgrade cwtch for the same
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2022-01-20 12:37:39 -05:00
parent c58be05110
commit 82a801678b
3 changed files with 7 additions and 1 deletions

2
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

4
lib.go
View File

@ -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)
}