in GetMessage, parse message with Attr[file-downloaded] to seed a CheckDownloadStatus call

This commit is contained in:
Dan Ballard 2021-12-21 10:16:24 -05:00
parent a1e06a868f
commit eafc5330b2
1 changed files with 21 additions and 2 deletions

23
lib.go
View File

@ -15,7 +15,6 @@ import (
"git.openprivacy.ca/cwtch.im/libcwtch-go/features"
// Import SQL Cipher
"os/user"
"runtime"
@ -526,6 +525,26 @@ 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)
if messages[0].Attr["file-downloaded"] == "true" {
var wrapper model.MessageWrapper
err := json.Unmarshal([]byte(messages[0].Body), &wrapper)
if err != nil {
log.Errorf("Couldn't decode MessageWrapper with attribute file-download:true: %v", err)
} else {
if wrapper.Overlay == model.OverlayFileSharing {
var fsOverlay filesharing.OverlayMessage
err = json.Unmarshal([]byte(wrapper.Data), &fsOverlay)
if err != nil {
log.Errorf("Couldn't decode message FileSharingOverlayMessage: %v", err)
} else {
CheckDownloadStatus(profileOnion, fsOverlay.Hash+"."+fsOverlay.Nonce)
}
} else {
log.Errorf("Message with attribute file-download:true has Overlay that is not filesharing:200, got %v", wrapper.Overlay)
}
}
}
}
}
bytes, _ := json.Marshal(message)
@ -886,7 +905,7 @@ func SetMessageAttribute(profileOnion string, conversationID int, channelID int,
}
//export c_ChangePassword
func c_ChangePassword(profile_ptr *C.char, profile_len C.int, oldpassword_ptr *C.char, oldpassword_len C.int, newpassword_ptr *C.char, newpassword_len C.int, newpassword_again_ptr *C.char, newpassword_again_len C.int) {
func c_ChangePassword(profile_ptr *C.char, profile_len C.int, oldpassword_ptr *C.char, oldpassword_len C.int, newpassword_ptr *C.char, newpassword_len C.int, newpassword_again_ptr *C.char, newpassword_again_len C.int) {
profileOnion := C.GoStringN(profile_ptr, profile_len)
oldPassword := C.GoStringN(oldpassword_ptr, oldpassword_len)
newPassword := C.GoStringN(newpassword_ptr, newpassword_len)