增加一次性群邀请链接和二维码
This commit is contained in:
1 parent
dfeb5bfefa
commit
5ec9c81f90
18 files changed
+727
-14
No files matched your search
@@ -289,6 +289,10 @@ func changeActive(ctx context.Context, tx pgx.Tx, user, id, owner, role string,
|
||||
return false, ErrAction
|
||||
}
|
||||
_, err = tx.Exec(ctx, "UPDATE group_members SET role='member' WHERE group_id=$1 AND user_id IN ($2,$3)", id, owner, change.Target)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
_, err = tx.Exec(ctx, "DELETE FROM group_invite_links WHERE group_id=$1", id)
|
||||
// The new owner establishes a new authenticated MLS session for the same roster.
|
||||
return true, err
|
||||
case "remove", "promote", "demote":
|
||||
@@ -302,13 +306,9 @@ func changeActive(ctx context.Context, tx pgx.Tx, user, id, owner, role string,
|
||||
}
|
||||
|
||||
func invite(ctx context.Context, tx pgx.Tx, user, id, target string) error {
|
||||
var count int
|
||||
if err := tx.QueryRow(ctx, "SELECT count(*) FROM group_members WHERE group_id=$1", id).Scan(&count); err != nil {
|
||||
if err := checkMemberLimit(ctx, tx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if count >= 32 {
|
||||
return ErrLimit
|
||||
}
|
||||
tag, err := tx.Exec(ctx, `
|
||||
INSERT INTO group_members(group_id,user_id,state)
|
||||
SELECT $1,$3,'invited' FROM contact_relationships
|
||||
@@ -322,6 +322,17 @@ func invite(ctx context.Context, tx pgx.Tx, user, id, target string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func checkMemberLimit(ctx context.Context, tx pgx.Tx, id string) error {
|
||||
var count int
|
||||
if err := tx.QueryRow(ctx, "SELECT count(*) FROM group_members WHERE group_id=$1", id).Scan(&count); err != nil {
|
||||
return err
|
||||
}
|
||||
if count >= 32 {
|
||||
return ErrLimit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func changeMember(ctx context.Context, tx pgx.Tx, id, role string, change Change) (bool, error) {
|
||||
if change.Action == "remove" {
|
||||
var state string
|
||||
|
||||
Reference in new issue
Block a user