package handlers import ( "git.coopgo.io/coopgo-platform/groups-management/storage" "github.com/google/uuid" ) func (h GroupsManagementHandler) AddGroupMember(group storage.GroupMember) (*storage.GroupMember, error) { if group.ID == "" { group.ID = uuid.NewString() } // Store the account if err := h.storage.CreateGroupMember(group); err != nil { return nil, err } return &group, nil } func (h GroupsManagementHandler) GetGroupMember(id string) (group *storage.GroupMember, err error) { group, err = h.storage.GetGroupMember(id) return } func (h GroupsManagementHandler) GetGroupsMember(namespaces []string) (groups []storage.GroupMember, err error) { groups, err = h.storage.GetGroupsMember(namespaces) return } func (h GroupsManagementHandler) GetGroupsBatchMember(groupids []string) (groups []storage.GroupMember, err error) { groups, err = h.storage.GetGroupsMemberByIds(groupids) return } func (h GroupsManagementHandler) SubscribeMember(group storage.GroupMember) (*storage.GroupMember, error) { groupp, err := h.storage.GetGroupMember(group.ID) if err != nil { groups := h.storage.CreateGroupMember(group) if groups != nil { return nil, err } else { h.storage.UpdateGroupMember(group) return &group, nil } } groupp.Memberid = group.Memberid groupp.Groupid = group.Groupid groupp.Data = group.Data h.storage.UpdateGroupMember(*groupp) return &group, nil } func (h GroupsManagementHandler) UnsubscribeMember(groupid string) error { _, err := h.storage.GetGroupMember(groupid) if err != nil { return err } erreur := h.storage.DeleteGroupMember(groupid) if erreur != nil { return erreur } return nil }