forked from cwtch.im/libcwtch-go
Merge pull request 'Upgrade Cwtch to v0.9.2' (#13) from bugfix into trunk
Reviewed-on: cwtch.im/libcwtch-go#13 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
41ae09d763
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.openprivacy.ca/flutter/libcwtch-go
|
|||
go 1.15
|
||||
|
||||
require (
|
||||
cwtch.im/cwtch v0.9.1
|
||||
cwtch.im/cwtch v0.9.2
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.4.5
|
||||
git.openprivacy.ca/openprivacy/log v1.0.2
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,5 +1,5 @@
|
|||
cwtch.im/cwtch v0.9.1 h1:xv883HaHxZhSXOCsOmuXJiKZoS3GoxQ4zictS4vRWGM=
|
||||
cwtch.im/cwtch v0.9.1/go.mod h1:EwUUVWIU4OAcz0HmHUxaY4orzKH6ZiNXaVI8y/5UP5k=
|
||||
cwtch.im/cwtch v0.9.2 h1:daDJPDWJ3uwRZ/UYPkmhpxxA/G8/FtFAQwbIGhM24ng=
|
||||
cwtch.im/cwtch v0.9.2/go.mod h1:EwUUVWIU4OAcz0HmHUxaY4orzKH6ZiNXaVI8y/5UP5k=
|
||||
git.openprivacy.ca/cwtch.im/tapir v0.4.4 h1:KyuTVmr9GYptTCeR7JDODjmhBBbnIBf9V3NSC4+6bHc=
|
||||
git.openprivacy.ca/cwtch.im/tapir v0.4.4/go.mod h1:qMFTdmDZITc1BLP1jSW0gVpLmvpg+Zjsh5ek8StwbFE=
|
||||
git.openprivacy.ca/openprivacy/bine v0.0.4 h1:CO7EkGyz+jegZ4ap8g5NWRuDHA/56KKvGySR6OBPW+c=
|
||||
|
|
54
lib.go
54
lib.go
|
@ -543,36 +543,40 @@ func GetMessage(profileOnion, handle string, message_index int) string {
|
|||
profile := application.GetPeer(profileOnion)
|
||||
ph := utils.NewPeerHelper(profile)
|
||||
if ph.IsGroup(handle) {
|
||||
// If we are safely within the limits of the timeline just grab the message at the index..
|
||||
if len(profile.GetGroup(handle).Timeline.Messages) > message_index {
|
||||
message.Message = profile.GetGroup(handle).Timeline.Messages[message_index]
|
||||
message.ContactImage = ph.GetProfilePic(message.Message.PeerID)
|
||||
} else {
|
||||
// Message Index Request exceeded Timeline, most likely reason is this is a request for an
|
||||
// unacknowledged sent message (it can take a many seconds for a message to be confirmed in the worst
|
||||
// case).
|
||||
offset := message_index - len(profile.GetGroup(handle).Timeline.Messages)
|
||||
if len(profile.GetGroup(handle).UnacknowledgedMessages) > offset {
|
||||
message.Message = profile.GetGroup(handle).UnacknowledgedMessages[offset]
|
||||
if profile.GetGroup(handle) != nil {
|
||||
// If we are safely within the limits of the timeline just grab the message at the index..
|
||||
if len(profile.GetGroup(handle).Timeline.Messages) > message_index {
|
||||
message.Message = profile.GetGroup(handle).Timeline.Messages[message_index]
|
||||
message.ContactImage = ph.GetProfilePic(message.Message.PeerID)
|
||||
} else {
|
||||
log.Errorf("Couldn't find message in timeline or unacked messages, probably transient threading issue, but logging for visibility..")
|
||||
// Message Index Request exceeded Timeline, most likely reason is this is a request for an
|
||||
// unacknowledged sent message (it can take a many seconds for a message to be confirmed in the worst
|
||||
// case).
|
||||
offset := message_index - len(profile.GetGroup(handle).Timeline.Messages)
|
||||
if len(profile.GetGroup(handle).UnacknowledgedMessages) > offset {
|
||||
message.Message = profile.GetGroup(handle).UnacknowledgedMessages[offset]
|
||||
message.ContactImage = ph.GetProfilePic(message.Message.PeerID)
|
||||
} else {
|
||||
log.Errorf("Couldn't find message in timeline or unacked messages, probably transient threading issue, but logging for visibility..")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If we are safely within the limits of the timeline just grab the message at the index..
|
||||
if len(profile.GetContact(handle).Timeline.Messages) > message_index {
|
||||
message.Message = profile.GetContact(handle).Timeline.Messages[message_index]
|
||||
message.ContactImage = ph.GetProfilePic(handle)
|
||||
} else {
|
||||
// Otherwise Send a counter resync event...this shouldn't really happen for p2p messages so we
|
||||
// throw an error.
|
||||
log.Errorf("peerpeercontact getmessage out of range; sending counter resync just in case")
|
||||
eventHandler.Push(event.NewEvent(event.MessageCounterResync, map[event.Field]string{
|
||||
event.Identity: profileOnion,
|
||||
event.RemotePeer: handle,
|
||||
event.Data: strconv.Itoa(len(profile.GetContact(handle).Timeline.Messages)),
|
||||
}))
|
||||
if profile.GetContact(handle) != nil {
|
||||
// If we are safely within the limits of the timeline just grab the message at the index..
|
||||
if len(profile.GetContact(handle).Timeline.Messages) > message_index {
|
||||
message.Message = profile.GetContact(handle).Timeline.Messages[message_index]
|
||||
message.ContactImage = ph.GetProfilePic(handle)
|
||||
} else {
|
||||
// Otherwise Send a counter resync event...this shouldn't really happen for p2p messages so we
|
||||
// throw an error.
|
||||
log.Errorf("peerpeercontact getmessage out of range; sending counter resync just in case")
|
||||
eventHandler.Push(event.NewEvent(event.MessageCounterResync, map[event.Field]string{
|
||||
event.Identity: profileOnion,
|
||||
event.RemotePeer: handle,
|
||||
event.Data: strconv.Itoa(len(profile.GetContact(handle).Timeline.Messages)),
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue