diff --git a/groupsv2/groupsv2.go b/groupsv2/groupsv2.go index 5a60aca..423cfe7 100644 --- a/groupsv2/groupsv2.go +++ b/groupsv2/groupsv2.go @@ -224,7 +224,15 @@ func (g *GroupV2) UpdateGroupFromServer() error { return nil } +func GetGroupV2MembersForGroup(group string) ([]*signalservice.DecryptedMember, error) { + g := FindGroup(group) + if g == nil { + return nil, fmt.Errorf("Group not found") + } + g.UpdateGroupFromServer() + return g.DecryptedGroup.Members, nil +} func HandleGroupsV2(src string, dm *signalservice.DataMessage) (*GroupV2, error) { groupContext := dm.GetGroupV2() if groupContext == nil { diff --git a/server.go b/server.go index 50f62ca..576fea4 100644 --- a/server.go +++ b/server.go @@ -23,6 +23,7 @@ import ( "github.com/signal-golang/textsecure/contactDiscoveryCrypto" "github.com/signal-golang/textsecure/contacts" "github.com/signal-golang/textsecure/contactsDiscovery" + "github.com/signal-golang/textsecure/groupsv2" "github.com/signal-golang/textsecure/profiles" signalservice "github.com/signal-golang/textsecure/protobuf" "github.com/signal-golang/textsecure/registration" @@ -395,6 +396,11 @@ func GetProfileAndCredential(uuid string, profileKey []byte) (*profiles.Profile, return profile, nil } +// GetGroupV2MembersForGroup returns the members of a group +func GetGroupV2MembersForGroup(group string) ([]*signalservice.DecryptedMember, error) { + return groupsv2.GetGroupV2MembersForGroup(group) +} + // GetMyUUID returns the uid from the current user func GetMyUUID() (string, error) { log.Debugln("[textsecure] get my uuid")