通过后端创建的群组,成员也能修改群组信息,有没有什么办法配置只有群主才能修改群组信息

莫语 2023-2-9 410

 //查询这些成员的IM账号
        List<TUser> tUsers = tCircleMemberMapper.selImAccountByCircleId(circleId);
        PojoGroupInfo pojoGroupInfo = new PojoGroupInfo();
        pojoGroupInfo.setName(tCircle.getCircleName());
        pojoGroupInfo.setOwner(tUser.getImAccount());
        pojoGroupInfo.setPortrait(tCircle.getCircleThumb());

        ArrayList<PojoGroupMember> pojoGroupMembers = new ArrayList<>();
        for (TUser user : tUsers) {
            PojoGroupMember pojoGroupMember = new PojoGroupMember();
            pojoGroupMember.setMember_id(user.getImAccount());
            pojoGroupMembers.add(pojoGroupMember);
        }

        try {
            IMResult<OutputCreateGroupResult> group = GroupAdmin.createGroup(tUser.getImAccount(), pojoGroupInfo, pojoGroupMembers, null, null);
            if (group.getCode() != 0) {
                throw new RuntimeException("创建群组失败");
            }
            //更新群组信息到圈子中
            tCircle.setGroupId(group.getResult().getGroup_id());
            int i = updateTCircle(tCircle);
            if (i > 0) {
                return success("创建群组成功");
            }
            throw new RuntimeException("创建群组失败");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
最新回复 (1)
  • HeavyRain 2023-2-9
    引用 2
    群信息有个type,可以参考 https://docs.wildfirechat.cn/blogs/群的一些细节问题.html
返回