forked from cwtch.im/cwtch
Add IndexedError for Peer Messages
This commit is contained in:
parent
95f288bac5
commit
b847fc42b8
|
@ -104,6 +104,12 @@ const (
|
||||||
// RemotePeer: The peer associated with the acknowledgement
|
// RemotePeer: The peer associated with the acknowledgement
|
||||||
IndexedAcknowledgement = Type("IndexedAcknowledgement")
|
IndexedAcknowledgement = Type("IndexedAcknowledgement")
|
||||||
|
|
||||||
|
// Like PeerAcknowledgement but with message index instead of event ID
|
||||||
|
// attributes
|
||||||
|
// Index: The original index of the message that the peer is responding too.
|
||||||
|
// RemotePeer: The peer associated with the acknowledgement
|
||||||
|
IndexedFailure = Type("IndexedFailure")
|
||||||
|
|
||||||
// attributes:
|
// attributes:
|
||||||
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
// RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
|
||||||
// Error: string describing the error
|
// Error: string describing the error
|
||||||
|
|
|
@ -183,7 +183,7 @@ func (p *Profile) AddMessageToContactTimeline(onion string, messageTxt string, s
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorSentMessageToPeer sets a sent message's error message and removes it from the unacknowledged list
|
// ErrorSentMessageToPeer sets a sent message's error message and removes it from the unacknowledged list
|
||||||
func (p *Profile) ErrorSentMessageToPeer(onion string, eventID string, error string) {
|
func (p *Profile) ErrorSentMessageToPeer(onion string, eventID string, error string) int {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
|
@ -191,10 +191,12 @@ func (p *Profile) ErrorSentMessageToPeer(onion string, eventID string, error str
|
||||||
if ok {
|
if ok {
|
||||||
mIdx, ok := contact.UnacknowledgedMessages[eventID]
|
mIdx, ok := contact.UnacknowledgedMessages[eventID]
|
||||||
if ok {
|
if ok {
|
||||||
p.Timeline.Messages[mIdx].Error = error
|
contact.Timeline.Messages[mIdx].Error = error
|
||||||
delete(contact.UnacknowledgedMessages, eventID)
|
delete(contact.UnacknowledgedMessages, eventID)
|
||||||
|
return mIdx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// AckSentMessageToPeer sets mesage to a peer as acknowledged
|
// AckSentMessageToPeer sets mesage to a peer as acknowledged
|
||||||
|
|
|
@ -20,7 +20,7 @@ const lastKnownSignature = "LastKnowSignature"
|
||||||
|
|
||||||
var autoHandleableEvents = map[event.Type]bool{event.EncryptedGroupMessage: true, event.PeerStateChange: true,
|
var autoHandleableEvents = map[event.Type]bool{event.EncryptedGroupMessage: true, event.PeerStateChange: true,
|
||||||
event.ServerStateChange: true, event.NewGroupInvite: true, event.NewMessageFromPeer: true,
|
event.ServerStateChange: true, event.NewGroupInvite: true, event.NewMessageFromPeer: true,
|
||||||
event.PeerAcknowledgement: true, event.PeerError: true, event.SendMessageToGroupError: true,
|
event.PeerAcknowledgement: true, event.PeerError: true, event.SendMessageToPeerError: true, event.SendMessageToGroupError: true,
|
||||||
event.NewGetValMessageFromPeer: true, event.NewRetValMessageFromPeer: true, event.ProtocolEngineStopped: true, event.RetryServerRequest: true}
|
event.NewGetValMessageFromPeer: true, event.NewRetValMessageFromPeer: true, event.ProtocolEngineStopped: true, event.RetryServerRequest: true}
|
||||||
|
|
||||||
// DefaultEventsToHandle specifies which events will be subscribed to
|
// DefaultEventsToHandle specifies which events will be subscribed to
|
||||||
|
@ -714,7 +714,10 @@ func (cp *cwtchPeer) eventHandler() {
|
||||||
|
|
||||||
case event.SendMessageToPeerError:
|
case event.SendMessageToPeerError:
|
||||||
cp.mutex.Lock()
|
cp.mutex.Lock()
|
||||||
cp.Profile.ErrorSentMessageToPeer(ev.Data[event.RemotePeer], ev.Data[event.EventID], ev.Data[event.Error])
|
idx := cp.Profile.ErrorSentMessageToPeer(ev.Data[event.RemotePeer], ev.Data[event.EventID], ev.Data[event.Error])
|
||||||
|
edata := ev.Data
|
||||||
|
edata[event.Index] = strconv.Itoa(idx)
|
||||||
|
cp.eventBus.Publish(event.NewEvent(event.IndexedFailure, edata))
|
||||||
cp.mutex.Unlock()
|
cp.mutex.Unlock()
|
||||||
case event.RetryServerRequest:
|
case event.RetryServerRequest:
|
||||||
// Automated Join Server Request triggered by a plugin.
|
// Automated Join Server Request triggered by a plugin.
|
||||||
|
|
|
@ -217,7 +217,11 @@ func (ps *ProfileStoreV1) ChangePassword(oldpass, newpass, eventID string) {
|
||||||
if len(ssid) == groupIDLen {
|
if len(ssid) == groupIDLen {
|
||||||
ps.profile.Groups[ssid].LocalID = newLocalID
|
ps.profile.Groups[ssid].LocalID = newLocalID
|
||||||
} else {
|
} else {
|
||||||
ps.profile.Contacts[ssid].LocalID = newLocalID
|
if ps.profile.Contacts[ssid] != nil {
|
||||||
|
ps.profile.Contacts[ssid].LocalID = newLocalID
|
||||||
|
} else {
|
||||||
|
log.Errorf("Unknown Contact: %v. This is probably the result of corrupted development data from fuzzing. This contact will not appear in the new profile.", ssid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue