This commit is contained in:
@@ -261,6 +261,34 @@ func (store *Store) MembershipsForUser(ctx context.Context, userID string) ([]or
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
func (store *Store) OrganizationMemberships(ctx context.Context, organizationID string, limit int) ([]organizations.Membership, error) {
|
||||
if !opaqueID(organizationID) || limit < 1 || limit > 2000 {
|
||||
return nil, errors.New("authsqlite: invalid organization member query")
|
||||
}
|
||||
rows, err := store.db.QueryContext(ctx, `SELECT m.user_id,m.status,m.joined_at
|
||||
FROM gwf_organization_memberships m
|
||||
JOIN gwf_organizations o ON o.id=m.organization_id
|
||||
WHERE m.organization_id=?
|
||||
ORDER BY m.joined_at,m.user_id
|
||||
LIMIT ?`, organizationID, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
result := make([]organizations.Membership, 0)
|
||||
for rows.Next() {
|
||||
var membership organizations.Membership
|
||||
var joined int64
|
||||
if err = rows.Scan(&membership.UserID, &membership.Status, &joined); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
membership.OrganizationID = organizationID
|
||||
membership.JoinedAt = time.Unix(joined, 0).UTC()
|
||||
result = append(result, membership)
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
func (store *Store) TeamsForUser(ctx context.Context, organizationID, userID string) ([]organizations.Team, error) {
|
||||
if !opaqueID(organizationID) || !opaqueID(userID) {
|
||||
return nil, errors.New("authsqlite: invalid team query")
|
||||
|
||||
Reference in New Issue
Block a user