Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f5b0692af | ||
|
|
2013e2b6ce | ||
|
|
35c040c476 | ||
|
|
31472bc5aa | ||
|
|
7e812a095f | ||
|
|
ec03b4632a | ||
|
|
c1d2c77837 | ||
|
|
5f50455169 | ||
|
|
499cfe7602 |
@@ -123,6 +123,9 @@ chatroom.participant_idle_time 900000
|
||||
## 用户向聊天室发送消息,自动加入聊天室
|
||||
chatroom.rejoin_when_active true
|
||||
|
||||
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||
chatroom.create_when_not_exist true
|
||||
|
||||
## 是否允许客户端发送操作群的自定义群通知消息
|
||||
group.allow_client_custom_operation_notification true
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.66</version>
|
||||
<version>0.67</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class AddFriendRequestAction extends AdminAction {
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
}, input.isForce());
|
||||
}, !input.isForce());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -152,6 +152,8 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
||||
public static final String CHATROOM_Create_When_Not_Exist = "chatroom.create_when_not_exist";
|
||||
|
||||
|
||||
public static final String GROUP_Allow_Client_Custom_Operation_Notification = "group.allow_client_custom_operation_notification";
|
||||
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ModifyGroupAliasHandler extends GroupHandler<WFCMessage.ModifyGroup
|
||||
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 (request.hasNotifyContent()&& request.getNotifyContent().getType() > 0 && (isAdmin || m_messagesStore.isAllowClientCustomGroupNotification())) {
|
||||
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;
|
||||
}
|
||||
|
||||
ErrorCode errorCode = m_messagesStore.modifyGroupAlias(fromUser, request.getGroupId(), request.getAlias(), request.getMemberId(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS && request.hasNotifyContent()) {
|
||||
ErrorCode errorCode = m_messagesStore.modifyGroupMemberAlias(fromUser, request.getGroupId(), request.getAlias(), 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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
private long mChatroomParticipantIdleTime = 900000;
|
||||
private boolean mChatroomRejoinWhenActive = true;
|
||||
private boolean mChatroomCreateWhenNotExist = true;
|
||||
|
||||
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
||||
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
||||
@@ -245,6 +246,14 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
printMissConfigLog(CHATROOM_Rejoin_When_Active, mChatroomRejoinWhenActive + "");
|
||||
}
|
||||
|
||||
try {
|
||||
mChatroomCreateWhenNotExist = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Create_When_Not_Exist));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
printMissConfigLog(CHATROOM_Create_When_Not_Exist, mChatroomCreateWhenNotExist + "");
|
||||
}
|
||||
|
||||
try {
|
||||
mChatroomParticipantIdleTime = Long.parseLong(m_Server.getConfig().getProperty(CHATROOM_Participant_Idle_Time, "900000"));
|
||||
} catch (Exception e) {
|
||||
@@ -1498,7 +1507,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
|
||||
@@ -1582,6 +1591,91 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
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
|
||||
public List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests) {
|
||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||
@@ -2976,7 +3070,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
||||
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
||||
if (chatroomInfoMap == null || chatroomInfoMap.get(chatroomId) == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
if(mChatroomCreateWhenNotExist) {
|
||||
WFCMessage.ChatroomInfo.Builder builder = WFCMessage.ChatroomInfo.newBuilder().setTitle(chatroomId);
|
||||
createChatroom(chatroomId, builder.build());
|
||||
} else {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
}
|
||||
|
||||
m_Server.getStore().sessionsStore().getSession(clientId).refreshLastChatroomActiveTime();
|
||||
|
||||
@@ -113,7 +113,8 @@ public interface IMessagesStore {
|
||||
void clearUserGroups(String userId);
|
||||
ErrorCode dismissGroup(String operator, String groupId, 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);
|
||||
WFCMessage.GroupInfo getGroupInfo(String groupId);
|
||||
Set<String> getUserGroupIds(String userId);
|
||||
|
||||
@@ -12,6 +12,7 @@ package win.liyufan.im;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -104,7 +105,11 @@ public class DBUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Flyway flyway = Flyway.configure().dataSource(comboPooledDataSource).locations(migrateLocation).baselineOnMigrate(true).load();
|
||||
if(!IsEmbedDB && (flyway.info().current() == null || flyway.info().current().getVersion().getMajor().intValue() < 43)) {
|
||||
System.out.println("数据库升级需要较长时间,可能长达数分钟或更长,请耐心等待,不要中断。。。");
|
||||
}
|
||||
flyway.migrate();
|
||||
|
||||
if(autoCleanMsgs) {
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface IMTopic {
|
||||
String ModifyGroupInfoTopic = "GMI";
|
||||
String ModifyGroupAliasTopic = "GMA";
|
||||
String ModifyGroupMemberAliasTopic = "GMMA";
|
||||
String ModifyGroupMemberExtraTopic = "GMME";
|
||||
String GetGroupInfoTopic = "GPGI";
|
||||
String GetGroupMemberTopic = "GPGM";
|
||||
String TransferGroupTopic = "GTG";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.66</version>
|
||||
<version>0.67</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public interface APIPath {
|
||||
String Group_Allow_Member = "/admin/group/manager/allow";
|
||||
String Get_User_Groups = "/admin/group/of_user";
|
||||
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 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_Modify_Info = "/robot/group/modify";
|
||||
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_Member_Quit = "/robot/group/member/quit";
|
||||
String Robot_Group_Transfer = "/robot/group/transfer";
|
||||
|
||||
@@ -133,6 +133,10 @@ public class GroupNotificationBinaryContent {
|
||||
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() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_MUTE);
|
||||
}
|
||||
@@ -164,5 +168,4 @@ public class GroupNotificationBinaryContent {
|
||||
public WFCMessage.MessageContent getChangeGroupExtraNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_EXTRA);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,9 +56,15 @@ public class InputCreateGroup extends InputGroupBase {
|
||||
if (group_info.private_chat > 0 && group_info.private_chat < 128) {
|
||||
groupInfoBuilder.setPrivateChat(group_info.private_chat);
|
||||
}
|
||||
if (group_info.searchable > 0) {
|
||||
if (group_info.searchable > 0 && group_info.searchable < 128) {
|
||||
groupInfoBuilder.setSearchable(group_info.searchable);
|
||||
}
|
||||
if(group_info.history_message > 0&& group_info.history_message < 128) {
|
||||
groupInfoBuilder.setHistoryMessage(group_info.history_message);
|
||||
}
|
||||
if(group_info.max_member_count > 0) {
|
||||
groupInfoBuilder.setMaxMemberCount(group_info.max_member_count);
|
||||
}
|
||||
|
||||
groupBuilder.setGroupInfo(groupInfoBuilder);
|
||||
for (PojoGroupMember pojoGroupMember : group.getMembers()) {
|
||||
|
||||
@@ -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_Type_Update = 3;
|
||||
int Group_Member_Event_Alias = 4;
|
||||
int Group_Member_Event_Extra = 5;
|
||||
}
|
||||
|
||||
public interface ChannelUpdateEventType {
|
||||
@@ -220,7 +221,6 @@ public class ProtoConstants {
|
||||
int Update_User_Name = 0x200;
|
||||
}
|
||||
|
||||
|
||||
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_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_KICKOF_GROUP_MEMBER_VISIBLE = 120;
|
||||
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_MEMBER_EXTRA = 123;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.66</version>
|
||||
<version>0.67</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -117,6 +117,9 @@ chatroom.participant_idle_time 900000
|
||||
## 用户向聊天室发送消息,自动加入聊天室
|
||||
chatroom.rejoin_when_active true
|
||||
|
||||
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||
chatroom.create_when_not_exist true
|
||||
|
||||
## 是否允许客户端发送操作群的自定义群通知消息
|
||||
group.allow_client_custom_operation_notification true
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.66</version>
|
||||
<version>0.67</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.66</version>
|
||||
<version>0.67</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.wildfirechat.sdk;
|
||||
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
public class AdminConfig {
|
||||
public static void initAdmin(String url, String secret) {
|
||||
AdminHttpUtils.init(url, secret);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupAdmin {
|
||||
@@ -152,6 +151,18 @@ public class GroupAdmin {
|
||||
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 {
|
||||
String path = APIPath.Get_User_Groups;
|
||||
InputUserId inputUserId = new InputUserId();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Main {
|
||||
|
||||
static void testAdmin() throws Exception {
|
||||
//初始化服务API
|
||||
AdminHttpUtils.init("http://localhost:18080", "123456");
|
||||
AdminConfig.initAdmin("http://localhost:18080", "123456");
|
||||
|
||||
testUser();
|
||||
testUserRelation();
|
||||
@@ -455,6 +455,13 @@ public class Main {
|
||||
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());
|
||||
if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -505,6 +512,14 @@ public class Main {
|
||||
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) {
|
||||
voidIMResult = GroupAdmin.setGroupManager("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -1119,7 +1134,7 @@ public class Main {
|
||||
//***测试频道API功能,仅专业版支持***
|
||||
static void testChannel() throws Exception {
|
||||
//初始化服务API
|
||||
AdminHttpUtils.init("http://localhost:18080", "123456");
|
||||
AdminConfig.initAdmin("http://localhost:18080", "123456");
|
||||
|
||||
//先创建3个用户
|
||||
InputOutputUserInfo userInfo = new InputOutputUserInfo();
|
||||
|
||||
@@ -203,4 +203,15 @@ public class RobotService {
|
||||
input.setNotify_message(notify_message);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -24,10 +26,12 @@ public class AdminHttpUtils {
|
||||
|
||||
private static String adminUrl;
|
||||
private static String adminSecret;
|
||||
private static CloseableHttpClient httpClient;
|
||||
|
||||
public static void init(String url, String secret) {
|
||||
adminUrl = url;
|
||||
adminSecret = secret;
|
||||
httpClient = HttpClients.createDefault();
|
||||
}
|
||||
|
||||
public static <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
||||
@@ -42,15 +46,13 @@ public class AdminHttpUtils {
|
||||
|
||||
String url = adminUrl + path;
|
||||
HttpPost post = null;
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
try {
|
||||
int nonce = (int)(Math.random() * 100000 + 3);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String str = nonce + "|" + adminSecret + "|" + timestamp;
|
||||
String sign = DigestUtils.sha1Hex(str);
|
||||
|
||||
|
||||
post = new HttpPost(url);
|
||||
post.setHeader("Content-type", "application/json; charset=utf-8");
|
||||
post.setHeader("Connection", "Keep-Alive");
|
||||
|
||||
@@ -9,7 +9,9 @@ import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -25,11 +27,13 @@ public class ChannelHttpUtils {
|
||||
private String imurl;
|
||||
private String channelId;
|
||||
private String channelSecret;
|
||||
private final CloseableHttpClient httpClient;
|
||||
|
||||
public ChannelHttpUtils(String imurl, String channelId, String secret) {
|
||||
this.imurl = imurl;
|
||||
this.channelId = channelId;
|
||||
this.channelSecret = secret;
|
||||
this.httpClient = HttpClients.createDefault();
|
||||
}
|
||||
|
||||
public <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
||||
@@ -41,8 +45,6 @@ public class ChannelHttpUtils {
|
||||
String url = imurl + path;
|
||||
HttpPost post = null;
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
int nonce = (int)(Math.random() * 100000 + 3);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String str = nonce + "|" + channelSecret + "|" + timestamp;
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -26,11 +28,13 @@ public class RobotHttpUtils {
|
||||
private final String url;
|
||||
private final String robotId;
|
||||
private final String robotSecret;
|
||||
private final CloseableHttpClient httpClient;
|
||||
|
||||
public RobotHttpUtils(String url, String robotId, String robotSecret) {
|
||||
this.url = url;
|
||||
this.robotId = robotId;
|
||||
this.robotSecret = robotSecret;
|
||||
this.httpClient = HttpClients.createDefault();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +47,6 @@ public class RobotHttpUtils {
|
||||
String url = this.url + path;
|
||||
HttpPost post = null;
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
int nonce = (int)(Math.random() * 100000 + 3);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String str = nonce + "|" + robotSecret + "|" + timestamp;
|
||||
|
||||
Reference in New Issue
Block a user