添加群组成员修改附加信息的功能
This commit is contained in:
Executable
+58
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.xiaoleilu.loServer.action.admin;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.InputSetGroupMemberExtra;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
|
import com.xiaoleilu.loServer.annotation.Route;
|
||||||
|
import com.xiaoleilu.loServer.handler.Request;
|
||||||
|
import com.xiaoleilu.loServer.handler.Response;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
@Route(APIPath.Group_Set_Member_Extra)
|
||||||
|
@HttpMethod("POST")
|
||||||
|
public class ModifyGroupMemberExtraAction extends AdminAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTransactionAction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean action(Request request, Response response) {
|
||||||
|
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||||
|
InputSetGroupMemberExtra inputSetGroupMemberExtra = getRequestBody(request.getNettyRequest(), InputSetGroupMemberExtra.class);
|
||||||
|
if (inputSetGroupMemberExtra.isValide()) {
|
||||||
|
sendApiMessage(response, inputSetGroupMemberExtra.getOperator(), IMTopic.ModifyGroupMemberExtraTopic, inputSetGroupMemberExtra.toProtoGroupRequest().toByteArray(), result -> {
|
||||||
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
|
byteBuf.writeBytes(result);
|
||||||
|
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||||
|
return new Result(errorCode);
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
response.setStatus(HttpResponseStatus.OK);
|
||||||
|
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||||
|
response.setContent(new Gson().toJson(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.xiaoleilu.loServer.action.robot;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.InputSetGroupMemberExtra;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
|
import com.xiaoleilu.loServer.annotation.Route;
|
||||||
|
import com.xiaoleilu.loServer.handler.Request;
|
||||||
|
import com.xiaoleilu.loServer.handler.Response;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
@Route(APIPath.Robot_Group_Set_Member_Extra)
|
||||||
|
@HttpMethod("POST")
|
||||||
|
public class ModifyGroupMemberExtraAction extends RobotAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTransactionAction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean action(Request request, Response response) {
|
||||||
|
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||||
|
InputSetGroupMemberExtra inputSetGroupMemberExtra = getRequestBody(request.getNettyRequest(), InputSetGroupMemberExtra.class);
|
||||||
|
inputSetGroupMemberExtra.setOperator(robot.getUid());
|
||||||
|
if (inputSetGroupMemberExtra.isValide()) {
|
||||||
|
sendApiRequest(response, IMTopic.ModifyGroupMemberExtraTopic, inputSetGroupMemberExtra.toProtoGroupRequest().toByteArray(), result -> {
|
||||||
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
|
byteBuf.writeBytes(result);
|
||||||
|
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||||
|
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
sendResponse(response, null, null);
|
||||||
|
} else {
|
||||||
|
sendResponse(response, errorCode, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
response.setStatus(HttpResponseStatus.OK);
|
||||||
|
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||||
|
response.setContent(new Gson().toJson(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class ModifyGroupAliasHandler extends GroupHandler<WFCMessage.ModifyGroup
|
|||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = m_messagesStore.modifyGroupAlias(fromUser, request.getGroupId(), request.getAlias(), null, isAdmin);
|
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), null, isAdmin);
|
||||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||||
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
||||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class ModifyGroupMemberAliasHandler extends GroupHandler<WFCMessage.Modif
|
|||||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = m_messagesStore.modifyGroupAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
||||||
if (errorCode == ERROR_CODE_SUCCESS && request.hasNotifyContent()) {
|
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||||
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
||||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.moquette.imhandler;
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import win.liyufan.im.IMTopic;
|
||||||
|
|
||||||
|
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@Handler(IMTopic.ModifyGroupMemberExtraTopic)
|
||||||
|
public class ModifyGroupMemberExtraHandler extends GroupHandler<WFCMessage.ModifyGroupMemberExtra> {
|
||||||
|
@Override
|
||||||
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ModifyGroupMemberExtra request, Qos1PublishHandler.IMCallback callback) {
|
||||||
|
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0 && !isAdmin && !m_messagesStore.isAllowClientCustomGroupNotification()) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode errorCode = m_messagesStore.modifyGroupMemberExtra(fromUser, request.getGroupId(), request.getExtra(), request.getMemberId(), isAdmin);
|
||||||
|
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||||
|
if (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
||||||
|
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||||
|
} else {
|
||||||
|
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getExtra(), request.getMemberId()).getModifyGroupMemberExtraNotifyContent();
|
||||||
|
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1498,7 +1498,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode modifyGroupAlias(String operator, String groupId, String alias, String memberId, boolean isAdmin) {
|
public ErrorCode modifyGroupMemberAlias(String operator, String groupId, String alias, String memberId, boolean isAdmin) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|
||||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||||
@@ -1582,6 +1582,91 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return ErrorCode.ERROR_CODE_SUCCESS;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode modifyGroupMemberExtra(String operator, String groupId, String extra, String memberId, boolean isAdmin) {
|
||||||
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|
||||||
|
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||||
|
WFCMessage.GroupInfo groupInfo = mIMap.get(groupId);
|
||||||
|
if (groupInfo == null) {
|
||||||
|
groupInfo = databaseStore.getPersistGroupInfo(groupId);
|
||||||
|
if (groupInfo != null) {
|
||||||
|
mIMap.set(groupId, groupInfo);
|
||||||
|
} else {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
|
||||||
|
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
|
||||||
|
if (members == null || members.size() == 0) {
|
||||||
|
members = loadGroupMemberFromDB(hzInstance, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtil.isNullOrEmpty(memberId)) {
|
||||||
|
memberId = operator;
|
||||||
|
} else {
|
||||||
|
if (!isAdmin && !operator.equals(groupInfo.getOwner())) {
|
||||||
|
WFCMessage.GroupMember operatorMember = null;
|
||||||
|
WFCMessage.GroupMember targetMember = null;
|
||||||
|
for (WFCMessage.GroupMember member : members) {
|
||||||
|
if (member.getMemberId().equals(operator)) {
|
||||||
|
operatorMember = member;
|
||||||
|
if (targetMember != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((member.getMemberId().equals(memberId))) {
|
||||||
|
targetMember = member;
|
||||||
|
if (operatorMember != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operatorMember == null) {
|
||||||
|
LOG.error("Modify group member extra error, the operator {} is not in group", operator);
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetMember == null) {
|
||||||
|
LOG.error("Modify group member extra error, the member {} is not in group", memberId);
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operatorMember.getType() == GroupMemberType_Manager && targetMember.getType() != GroupMemberType_Manager) {
|
||||||
|
LOG.error("Modify group member extra error, the operator {} type is {} and the member {} type is {}", operator, operatorMember.getType(), memberId, targetMember.getType());
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long updateDt = System.currentTimeMillis();
|
||||||
|
|
||||||
|
boolean inGroup = false;
|
||||||
|
for (WFCMessage.GroupMember member : members) {
|
||||||
|
if (member.getMemberId().equals(memberId)) {
|
||||||
|
groupMembers.remove(groupId, member);
|
||||||
|
member = member.toBuilder().setExtra(extra).setUpdateDt(updateDt).build();
|
||||||
|
databaseStore.persistGroupMember(groupId, Arrays.asList(member), false);
|
||||||
|
databaseStore.updateGroupMemberDt(groupId, updateDt);
|
||||||
|
groupMembers.put(groupId, member);
|
||||||
|
|
||||||
|
mIMap.set(groupId, groupInfo.toBuilder().setUpdateDt(updateDt).setMemberUpdateDt(updateDt).build());
|
||||||
|
inGroup = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inGroup) {
|
||||||
|
LOG.error("Modify group member extra error, the member {} is not in group", memberId);
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
callbackGroupMemberEvent(operator, groupId, Arrays.asList(memberId), ProtoConstants.GroupMemberUpdateEventType.Group_Member_Event_Alias, extra);
|
||||||
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests) {
|
public List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ public interface IMessagesStore {
|
|||||||
void clearUserGroups(String userId);
|
void clearUserGroups(String userId);
|
||||||
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
|
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
|
||||||
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin);
|
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin);
|
||||||
ErrorCode modifyGroupAlias(String operator, String groupId, String alias, String memberId, boolean isAdmin);
|
ErrorCode modifyGroupMemberAlias(String operator, String groupId, String alias, String memberId, boolean isAdmin);
|
||||||
|
ErrorCode modifyGroupMemberExtra(String operator, String groupId, String extra, String memberId, boolean isAdmin);
|
||||||
List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests);
|
List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests);
|
||||||
WFCMessage.GroupInfo getGroupInfo(String groupId);
|
WFCMessage.GroupInfo getGroupInfo(String groupId);
|
||||||
Set<String> getUserGroupIds(String userId);
|
Set<String> getUserGroupIds(String userId);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public interface IMTopic {
|
|||||||
String ModifyGroupInfoTopic = "GMI";
|
String ModifyGroupInfoTopic = "GMI";
|
||||||
String ModifyGroupAliasTopic = "GMA";
|
String ModifyGroupAliasTopic = "GMA";
|
||||||
String ModifyGroupMemberAliasTopic = "GMMA";
|
String ModifyGroupMemberAliasTopic = "GMMA";
|
||||||
|
String ModifyGroupMemberExtraTopic = "GMME";
|
||||||
String GetGroupInfoTopic = "GPGI";
|
String GetGroupInfoTopic = "GPGI";
|
||||||
String GetGroupMemberTopic = "GPGM";
|
String GetGroupMemberTopic = "GPGM";
|
||||||
String TransferGroupTopic = "GTG";
|
String TransferGroupTopic = "GTG";
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public interface APIPath {
|
|||||||
String Group_Allow_Member = "/admin/group/manager/allow";
|
String Group_Allow_Member = "/admin/group/manager/allow";
|
||||||
String Get_User_Groups = "/admin/group/of_user";
|
String Get_User_Groups = "/admin/group/of_user";
|
||||||
String Group_Set_Member_Alias = "/admin/group/member/set_alias";
|
String Group_Set_Member_Alias = "/admin/group/member/set_alias";
|
||||||
|
String Group_Set_Member_Extra = "/admin/group/member/set_extra";
|
||||||
|
|
||||||
String Create_Channel = "/admin/channel/create";
|
String Create_Channel = "/admin/channel/create";
|
||||||
String Get_System_Setting = "/admin/system/get_setting";
|
String Get_System_Setting = "/admin/system/get_setting";
|
||||||
@@ -101,6 +102,7 @@ public interface APIPath {
|
|||||||
String Robot_Group_Member_Kickoff = "/robot/group/member/del";
|
String Robot_Group_Member_Kickoff = "/robot/group/member/del";
|
||||||
String Robot_Group_Modify_Info = "/robot/group/modify";
|
String Robot_Group_Modify_Info = "/robot/group/modify";
|
||||||
String Robot_Group_Set_Member_Alias = "/robot/group/member/set_alias";
|
String Robot_Group_Set_Member_Alias = "/robot/group/member/set_alias";
|
||||||
|
String Robot_Group_Set_Member_Extra = "/robot/group/member/set_extra";
|
||||||
String Robot_Group_Mute_Member = "/robot/group/manager/mute";
|
String Robot_Group_Mute_Member = "/robot/group/manager/mute";
|
||||||
String Robot_Group_Member_Quit = "/robot/group/member/quit";
|
String Robot_Group_Member_Quit = "/robot/group/member/quit";
|
||||||
String Robot_Group_Transfer = "/robot/group/transfer";
|
String Robot_Group_Transfer = "/robot/group/transfer";
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ public class GroupNotificationBinaryContent {
|
|||||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS);
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WFCMessage.MessageContent getModifyGroupMemberExtraNotifyContent() {
|
||||||
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_MEMBER_EXTRA);
|
||||||
|
}
|
||||||
|
|
||||||
public WFCMessage.MessageContent getChangeGroupMuteNotifyContent() {
|
public WFCMessage.MessageContent getChangeGroupMuteNotifyContent() {
|
||||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_MUTE);
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_MUTE);
|
||||||
}
|
}
|
||||||
@@ -164,5 +168,4 @@ public class GroupNotificationBinaryContent {
|
|||||||
public WFCMessage.MessageContent getChangeGroupExtraNotifyContent() {
|
public WFCMessage.MessageContent getChangeGroupExtraNotifyContent() {
|
||||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_EXTRA);
|
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Wildfire Chat package.
|
||||||
|
* (c) Heavyrain2012 <[email protected]>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.wildfirechat.pojos;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
|
|
||||||
|
public class InputSetGroupMemberExtra extends InputGroupBase {
|
||||||
|
private String group_id;
|
||||||
|
private String memberId;
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
public String getGroup_id() {
|
||||||
|
return group_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup_id(String group_id) {
|
||||||
|
this.group_id = group_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValide() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WFCMessage.ModifyGroupMemberExtra toProtoGroupRequest() {
|
||||||
|
WFCMessage.ModifyGroupMemberExtra.Builder modifyAliasBuilder = WFCMessage.ModifyGroupMemberExtra.newBuilder();
|
||||||
|
modifyAliasBuilder.setGroupId(group_id);
|
||||||
|
modifyAliasBuilder.setMemberId(memberId);
|
||||||
|
modifyAliasBuilder.setExtra(StringUtil.isNullOrEmpty(extra)?"": extra);
|
||||||
|
|
||||||
|
if (to_lines != null) {
|
||||||
|
for (Integer line : to_lines) {
|
||||||
|
modifyAliasBuilder.addToLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notify_message != null) {
|
||||||
|
modifyAliasBuilder.setNotifyContent(notify_message.toProtoMessageContent());
|
||||||
|
}
|
||||||
|
return modifyAliasBuilder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(String memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra(String extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -185,6 +185,7 @@ public class ProtoConstants {
|
|||||||
int Group_Member_Event_Kickoff = 2;
|
int Group_Member_Event_Kickoff = 2;
|
||||||
int Group_Member_Event_Type_Update = 3;
|
int Group_Member_Event_Type_Update = 3;
|
||||||
int Group_Member_Event_Alias = 4;
|
int Group_Member_Event_Alias = 4;
|
||||||
|
int Group_Member_Event_Extra = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ChannelUpdateEventType {
|
public interface ChannelUpdateEventType {
|
||||||
@@ -220,7 +221,6 @@ public class ProtoConstants {
|
|||||||
int Update_User_Name = 0x200;
|
int Update_User_Name = 0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104;
|
public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104;
|
||||||
public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105;
|
public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105;
|
||||||
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106;
|
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106;
|
||||||
@@ -241,7 +241,8 @@ public class ProtoConstants {
|
|||||||
public static final int MESSAGE_CONTENT_TYPE_ALLOW_MEMBER = 119;
|
public static final int MESSAGE_CONTENT_TYPE_ALLOW_MEMBER = 119;
|
||||||
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER_VISIBLE = 120;
|
public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER_VISIBLE = 120;
|
||||||
public static final int MESSAGE_CONTENT_TYPE_QUIT_GROUP_VISIBLE = 121;
|
public static final int MESSAGE_CONTENT_TYPE_QUIT_GROUP_VISIBLE = 121;
|
||||||
|
|
||||||
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_EXTRA = 122;
|
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_EXTRA = 122;
|
||||||
|
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_MEMBER_EXTRA = 123;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@ import cn.wildfirechat.pojos.*;
|
|||||||
import cn.wildfirechat.sdk.model.IMResult;
|
import cn.wildfirechat.sdk.model.IMResult;
|
||||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GroupAdmin {
|
public class GroupAdmin {
|
||||||
@@ -152,6 +151,18 @@ public class GroupAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> setGroupMemberExtra(String operator, String groupId, String memberId, String extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||||
|
String path = APIPath.Group_Set_Member_Extra;
|
||||||
|
InputSetGroupMemberExtra input = new InputSetGroupMemberExtra();
|
||||||
|
input.setGroup_id(groupId);
|
||||||
|
input.setOperator(operator);
|
||||||
|
input.setMemberId(memberId);
|
||||||
|
input.setExtra(extra);
|
||||||
|
input.setTo_lines(to_lines);
|
||||||
|
input.setNotify_message(notify_message);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
public static IMResult<OutputGroupIds> getUserGroups(String user) throws Exception {
|
||||||
String path = APIPath.Get_User_Groups;
|
String path = APIPath.Get_User_Groups;
|
||||||
InputUserId inputUserId = new InputUserId();
|
InputUserId inputUserId = new InputUserId();
|
||||||
|
|||||||
@@ -455,6 +455,13 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
voidIMResult = GroupAdmin.modifyGroupInfo(groupInfo.getOwner(), groupInfo.getTarget_id(), ProtoConstants.ModifyGroupInfoType.Modify_Group_Extra,"HelloWorld2", null, null);
|
||||||
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("modify group extra success");
|
||||||
|
} else {
|
||||||
|
System.out.println("modify group extra failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
resultGetGroupInfo = GroupAdmin.getGroupInfo(groupInfo.getTarget_id());
|
resultGetGroupInfo = GroupAdmin.getGroupInfo(groupInfo.getTarget_id());
|
||||||
if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
@@ -505,6 +512,14 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
voidIMResult = GroupAdmin.setGroupMemberExtra(groupInfo.getOwner(), groupInfo.getTarget_id(), groupInfo.getOwner(), "hello member extra2", null, null);
|
||||||
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("set group member extra success");
|
||||||
|
} else {
|
||||||
|
System.out.println("set group member extra failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
if(commercialServer) {
|
if(commercialServer) {
|
||||||
voidIMResult = GroupAdmin.setGroupManager("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
voidIMResult = GroupAdmin.setGroupManager("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
|||||||
@@ -203,4 +203,15 @@ public class RobotService {
|
|||||||
input.setNotify_message(notify_message);
|
input.setNotify_message(notify_message);
|
||||||
return robotHttpUtils.httpJsonPost(path, input, Void.class);
|
return robotHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IMResult<Void> setGroupMemberExtra(String groupId, String memberId, String extra, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||||
|
String path = APIPath.Robot_Group_Set_Member_Extra;
|
||||||
|
InputSetGroupMemberExtra input = new InputSetGroupMemberExtra();
|
||||||
|
input.setGroup_id(groupId);
|
||||||
|
input.setMemberId(memberId);
|
||||||
|
input.setExtra(extra);
|
||||||
|
input.setTo_lines(to_lines);
|
||||||
|
input.setNotify_message(notify_message);
|
||||||
|
return robotHttpUtils.httpJsonPost(path, input, Void.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user