Send Indexed Failure on Send Error #418
|
@ -1031,14 +1031,14 @@ func (cp *cwtchPeer) eventHandler() {
|
||||||
log.Debugf("failed to acknowledge acknowledgement: %v", err)
|
log.Debugf("failed to acknowledge acknowledgement: %v", err)
|
||||||
}
|
}
|
||||||
case event.SendMessageToGroupError:
|
case event.SendMessageToGroupError:
|
||||||
err := cp.attemptErrorConversationMessage(ev.Data[event.GroupID], ev.Data[event.Signature], event.SendMessageToGroupError, ev.Data[event.Error])
|
err := cp.attemptErrorConversationMessage(ev.Data[event.GroupID], ev.Data[event.Signature], ev.Data[event.Error])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to error group message: %s %v", ev.Data[event.GroupID], err)
|
log.Errorf("failed to error group message: %s %v", ev.Data[event.GroupID], err)
|
||||||
}
|
}
|
||||||
case event.SendMessageToPeerError:
|
case event.SendMessageToPeerError:
|
||||||
context := ev.Data[event.EventContext]
|
context := ev.Data[event.EventContext]
|
||||||
if context == string(event.SendMessageToPeer) {
|
if context == string(event.SendMessageToPeer) {
|
||||||
err := cp.attemptErrorConversationMessage(ev.Data[event.RemotePeer], ev.Data[event.EventID], event.SendMessageToPeerError, ev.Data[event.Error])
|
err := cp.attemptErrorConversationMessage(ev.Data[event.RemotePeer], ev.Data[event.EventID], ev.Data[event.Error])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to error p2p message: %s %v", ev.Data[event.RemotePeer], err)
|
log.Errorf("failed to error p2p message: %s %v", ev.Data[event.RemotePeer], err)
|
||||||
}
|
}
|
||||||
|
@ -1243,11 +1243,11 @@ func (cp *cwtchPeer) attemptAcknowledgeP2PConversation(handle string, signature
|
||||||
// attemptErrorConversationMessage is a convenience method that looks up the conversation
|
// attemptErrorConversationMessage is a convenience method that looks up the conversation
|
||||||
// by the given handle and attempts to mark the message as errored. returns error on failure
|
// by the given handle and attempts to mark the message as errored. returns error on failure
|
||||||
// to either find the contact or the associated message
|
// to either find the contact or the associated message
|
||||||
func (cp *cwtchPeer) attemptErrorConversationMessage(handle string, signature string, eventType event.Type, error string) error {
|
func (cp *cwtchPeer) attemptErrorConversationMessage(handle string, signature string, error string) error {
|
||||||
ci, err := cp.FetchConversationInfo(handle)
|
ci, err := cp.FetchConversationInfo(handle)
|
||||||
// We should *never* received a peer acknowledgement for a conversation that doesn't exist...
|
// We should *never* received an error for a conversation that doesn't exist...
|
||||||
if ci != nil && err == nil {
|
if ci != nil && err == nil {
|
||||||
// for p2p messages the randomly generated event ID is the "signature"
|
// "signature" here is event ID for peer messages...
|
||||||
id, err := cp.GetChannelMessageBySignature(ci.ID, 0, signature)
|
id, err := cp.GetChannelMessageBySignature(ci.ID, 0, signature)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, attr, err := cp.GetChannelMessage(ci.ID, 0, id)
|
_, attr, err := cp.GetChannelMessage(ci.ID, 0, id)
|
||||||
|
@ -1256,7 +1256,8 @@ func (cp *cwtchPeer) attemptErrorConversationMessage(handle string, signature st
|
||||||
attr[constants.AttrErr] = constants.True
|
attr[constants.AttrErr] = constants.True
|
||||||
cp.storage.UpdateMessageAttributes(ci.ID, 0, id, attr)
|
cp.storage.UpdateMessageAttributes(ci.ID, 0, id, attr)
|
||||||
cp.mutex.Unlock()
|
cp.mutex.Unlock()
|
||||||
cp.eventBus.Publish(event.NewEvent(eventType, map[event.Field]string{event.ConversationID: strconv.Itoa(ci.ID), event.RemotePeer: handle, event.Error: error, event.Index: strconv.Itoa(id)}))
|
// Send a generic indexed failure...
|
||||||
|
cp.eventBus.Publish(event.NewEvent(event.IndexedFailure, map[event.Field]string{event.ConversationID: strconv.Itoa(ci.ID), event.Handle: handle, event.Error: error, event.Index: strconv.Itoa(id)}))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue