Skip to content

Commit

Permalink
fix(ci): tests
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Apr 2, 2019
1 parent c362203 commit 71213ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
42 changes: 29 additions & 13 deletions core/entity/conversation.go
Expand Up @@ -78,29 +78,45 @@ func NewGroupConversation(contacts []*Contact) (*Conversation, error) {
Members: []*ConversationMember{},
}

// get myself from contacts
var myself *Contact
for _, contact := range contacts {
// create the member
member, err := NewConversationMember(contact, c)
if err != nil {
return nil, errorcodes.ErrConversation.Wrap(err)
if contact.Status == Contact_Myself {
myself = contact
}

c.Members = append(c.Members, member)
}
if myself == nil {
return nil, errorcodes.ErrConversation.Wrap(
errorcodes.ErrConversationMembers.New(),
)
}

var myselfID string
for _, contact := range contacts {
if contact.Status == Contact_Myself {
myselfID = contact.ID
}
// add myself as converastion member
mm, err := NewConversationMember(myself, c)
if err != nil {
return nil, errorcodes.ErrConversation.Wrap(err)
}
c.Members = append(c.Members, mm)

im, err := c.GetInteractiveMember(myselfID)
// get interactive member
im, err := c.GetInteractiveMember(myself.ID)
if err != nil {
return nil, err
}

if err = im.SetOwner(myselfID); err != nil {
// invite the contacts
for _, contact := range contacts {
// create the member
if contact.ID == myself.ID {
continue
}
if err := im.Invite(contact); err != nil {
return nil, err
}
}

// set myself as owner
if err = im.SetOwner(myself.ID); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion core/node/nodeapi.go
Expand Up @@ -275,7 +275,7 @@ func (n *Node) ContactRequest(ctx context.Context, req *node.ContactRequestInput
}

// create conversation if doesn't exist
if _, err := n.ConversationCreate(ctx,
if _, err := n.conversationCreate(ctx,
&node.ConversationCreateInput{
Contacts: []*entity.Contact{contact},
Kind: entity.Conversation_OneToOne,
Expand Down

0 comments on commit 71213ad

Please sign in to comment.