mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 04:55:59 +08:00
Merge remote-tracking branch 'origin/superGroup' into superGroup
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package base_info
|
||||
|
||||
type GetJoinedSuperGroupReq struct {
|
||||
type GetJoinedSuperGroupListReq struct {
|
||||
GetJoinedGroupListReq
|
||||
}
|
||||
|
||||
type GetJoinedSuperGroupResp struct {
|
||||
type GetJoinedSuperGroupListResp struct {
|
||||
GetJoinedGroupListResp
|
||||
}
|
||||
|
||||
|
||||
@@ -985,10 +985,13 @@ func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string,
|
||||
opts := &options.UpdateOptions{
|
||||
Upsert: &upsert,
|
||||
}
|
||||
_, err = c.UpdateMany(sCtx, bson.M{"user_id": bson.M{"$in": initMemberIDList}}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
||||
for _, userID := range initMemberIDList {
|
||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
}
|
||||
session.CommitTransaction(ctx)
|
||||
return err
|
||||
@@ -1026,10 +1029,16 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
|
||||
UserID: v,
|
||||
})
|
||||
}
|
||||
_, err = c.UpdateMany(sCtx, users, bson.M{"$addToSet": bson.M{"group_id_list": groupID}})
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
upsert := true
|
||||
opts := &options.UpdateOptions{
|
||||
Upsert: &upsert,
|
||||
}
|
||||
for _, userID := range userIDList {
|
||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
||||
if err != nil {
|
||||
session.AbortTransaction(ctx)
|
||||
return utils.Wrap(err, "transaction failed")
|
||||
}
|
||||
}
|
||||
session.CommitTransaction(ctx)
|
||||
return err
|
||||
@@ -1097,7 +1106,7 @@ func (d *DataBases) RemoveGroupFromUser(ctx, sCtx context.Context, groupID strin
|
||||
})
|
||||
}
|
||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
||||
_, err := c.UpdateOne(sCtx, bson.M{"user_id": groupID}, bson.M{"$pull": bson.M{"group_id_list": groupID}})
|
||||
_, err := c.UpdateOne(sCtx, bson.M{"user_id": bson.M{"$in": userID}}, bson.M{"$pull": bson.M{"group_id_list": groupID}})
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "UpdateOne transaction failed")
|
||||
}
|
||||
|
||||
+345
-207
File diff suppressed because it is too large
Load Diff
@@ -401,6 +401,16 @@ message GetJoinedSuperGroupListResp {
|
||||
repeated server_api_params.GroupInfo GroupList = 3;
|
||||
}
|
||||
|
||||
message GetSuperGroupsInfoReq {
|
||||
repeated string GroupIDList = 1;
|
||||
string OperationID = 2;
|
||||
string OpUserID = 3; //No verification permission
|
||||
}
|
||||
|
||||
message GetSuperGroupsInfoResp {
|
||||
CommonResp commonResp = 1;
|
||||
repeated server_api_params.GroupInfo GroupInfoList = 3;
|
||||
}
|
||||
|
||||
service group{
|
||||
rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
|
||||
@@ -438,6 +448,7 @@ service group{
|
||||
rpc SetGroupMemberNickname(SetGroupMemberNicknameReq) returns (SetGroupMemberNicknameResp);
|
||||
|
||||
rpc GetJoinedSuperGroupList(GetJoinedSuperGroupListReq) returns (GetJoinedSuperGroupListResp);
|
||||
rpc GetSuperGroupsInfo(GetSuperGroupsInfoReq) returns (GetSuperGroupsInfoResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user