Skip to content
Snippets Groups Projects
Commit 8ea3b99e authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

changed group creation over bindings so errors are returns as strings as part of the report object

parent 8a77b59a
No related branches found
No related tags found
1 merge request!67Release
...@@ -62,10 +62,13 @@ func NewGroupManager(client *Client, requestFunc GroupRequestFunc, ...@@ -62,10 +62,13 @@ func NewGroupManager(client *Client, requestFunc GroupRequestFunc,
// MakeGroup creates a new group and sends a group request to all members in the // MakeGroup creates a new group and sends a group request to all members in the
// group. The ID of the new group, the rounds the requests were sent on, and the // group. The ID of the new group, the rounds the requests were sent on, and the
// status of the send are contained in NewGroupReport. // status of the send are contained in NewGroupReport.
func (g *GroupChat) MakeGroup(membership *IdList, name, message []byte) ( func (g *GroupChat) MakeGroup(membership *IdList, name, message []byte)*NewGroupReport {
*NewGroupReport, error) {
grp, rounds, status, err := g.m.MakeGroup(membership.list, name, message) grp, rounds, status, err := g.m.MakeGroup(membership.list, name, message)
return &NewGroupReport{&Group{grp}, rounds, status}, err errStr := ""
if err !=nil{
errStr = err.Error()
}
return &NewGroupReport{&Group{grp}, rounds, status, errStr}
} }
// ResendRequest resends a group request to all members in the group. The rounds // ResendRequest resends a group request to all members in the group. The rounds
...@@ -77,9 +80,18 @@ func (g *GroupChat) ResendRequest(groupIdBytes []byte) (*NewGroupReport, error) ...@@ -77,9 +80,18 @@ func (g *GroupChat) ResendRequest(groupIdBytes []byte) (*NewGroupReport, error)
errors.Errorf("Failed to unmarshal group ID: %+v", err) errors.Errorf("Failed to unmarshal group ID: %+v", err)
} }
grp, exists := g.m.GetGroup(groupID)
if !exists{
return nil,errors.Errorf("Failed to find group %s", groupID)
}
rounds, status, err := g.m.ResendRequest(groupID) rounds, status, err := g.m.ResendRequest(groupID)
return &NewGroupReport{&Group{}, rounds, status}, nil errStr := ""
if err !=nil{
errStr = err.Error()
}
return &NewGroupReport{&Group{grp}, rounds, status, errStr}, nil
} }
// JoinGroup allows a user to join a group when they receive a request. The // JoinGroup allows a user to join a group when they receive a request. The
...@@ -152,6 +164,7 @@ type NewGroupReport struct { ...@@ -152,6 +164,7 @@ type NewGroupReport struct {
group *Group group *Group
rounds []id.Round rounds []id.Round
status gc.RequestStatus status gc.RequestStatus
err string
} }
// GetGroup returns the Group. // GetGroup returns the Group.
...@@ -167,13 +180,19 @@ func (ngr *NewGroupReport) GetRoundList() *RoundList { ...@@ -167,13 +180,19 @@ func (ngr *NewGroupReport) GetRoundList() *RoundList {
// GetStatus returns the status of the requests sent when creating a new group. // GetStatus returns the status of the requests sent when creating a new group.
// status = 0 an error occurred before any requests could be sent // status = 0 an error occurred before any requests could be sent
// 1 all requests failed to send // 1 all requests failed to send (call Resend Group)
// 2 some request failed and some succeeded // 2 some request failed and some succeeded (call Resend Group)
// 3, all requests sent successfully // 3, all requests sent successfully (call Resend Group)
func (ngr *NewGroupReport) GetStatus() int { func (ngr *NewGroupReport) GetStatus() int {
return int(ngr.status) return int(ngr.status)
} }
// GetError returns the string of an error.
// Will be an empty string if no error occured
func (ngr *NewGroupReport) GetError() string {
return ngr.err
}
//// ////
// NewGroupReport Structure // NewGroupReport Structure
//// ////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment