Skip to content

Commit

Permalink
feat: handle errors on conversation delete
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jan 9, 2019
1 parent ccd9427 commit 28492b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/node/nodeapi.go
Expand Up @@ -358,8 +358,12 @@ func (n *Node) ContactRemove(ctx context.Context, contact *entity.Contact) (*ent
// remove 1-1 conversation
// don't return error if not found
conversation, err := bsql.ConversationOneToOne(sql, n.config.Myself.ID, contact.ID)
if err == nil {
switch {
case err == nil: // conversation exists, delete it
n.ConversationRemove(ctx, &entity.Conversation{ID: conversation.ID})
case gorm.IsRecordNotFoundError(errors.Cause(err)): // conversation is not found, do nothing
case err != nil: // another error is triggered, returning it
return nil, err
}

return contact, nil
Expand Down

0 comments on commit 28492b5

Please sign in to comment.