diff --git a/lib.go b/lib.go index b2618b3..e9c59bd 100644 --- a/lib.go +++ b/lib.go @@ -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)