重构
This commit is contained in:
@@ -40,6 +40,32 @@ abstract public class Action {
|
||||
public ChannelHandlerContext ctx;
|
||||
public Response response;
|
||||
|
||||
protected class Result {
|
||||
Object data;
|
||||
ErrorCode errorCode;
|
||||
|
||||
public Result(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public Result(ErrorCode errorCode, Object data) {
|
||||
this.data = data;
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
protected interface ApiCallback {
|
||||
Result onResult(byte[] response);
|
||||
}
|
||||
|
||||
public ErrorCode preAction(Request request, Response response) {
|
||||
if (getClass().getAnnotation(RequireAuthentication.class) != null) {
|
||||
//do authentication
|
||||
@@ -94,4 +120,9 @@ abstract public class Action {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setResponseContent(RestResult result) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -45,11 +45,7 @@ public class AddFriendRequestAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,17 +41,11 @@ public class AddGroupMemberAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -33,10 +33,6 @@ abstract public class AdminAction extends Action {
|
||||
SECRET_KEY = secretKey;
|
||||
}
|
||||
|
||||
protected interface Callback {
|
||||
void onSuccess(byte[] response);
|
||||
}
|
||||
|
||||
public static void setNoCheckTime(String noCheckTime) {
|
||||
try {
|
||||
NO_CHECK_TIME = Boolean.parseBoolean(noCheckTime);
|
||||
@@ -97,12 +93,13 @@ abstract public class AdminAction extends Action {
|
||||
response.send();
|
||||
}
|
||||
|
||||
protected void sendApiMessage(String fromUser, String topic, byte[] message, Callback callback) {
|
||||
protected void sendApiMessage(String fromUser, String topic, byte[] message, ApiCallback callback) {
|
||||
ServerAPIHelper.sendRequest(fromUser, null, topic, message, new ServerAPIHelper.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
if(callback != null) {
|
||||
callback.onSuccess(result);
|
||||
Result r = callback.onResult(result);
|
||||
sendResponse(response, r.getErrorCode(), r.getData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetAlias;
|
||||
import cn.wildfirechat.pojos.InputGetFriendList;
|
||||
import cn.wildfirechat.pojos.OutputGetAlias;
|
||||
@@ -49,9 +50,8 @@ public class AliasGetAction extends AdminAction {
|
||||
break;
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok(out));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ public class AliasPutAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputUpdateAlias input = getRequestBody(request.getNettyRequest(), InputUpdateAlias.class);
|
||||
ErrorCode errorCode = messagesStore.setFriendAliasRequest(input.getOperator(), input.getTargetId(), input.getAlias(), new long[1]);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(errorCode));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,17 +46,11 @@ public class BlacklistAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,9 +45,7 @@ public class BlacklistGetAction extends AdminAction {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputStringList(list)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ public class BlockUserAction extends AdminAction {
|
||||
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-5
@@ -46,16 +46,14 @@ public class BroadcastMessageAction extends AdminAction {
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long count = byteBuf.readLong();
|
||||
sendResponse(response, null, new BroadMessageResult(messageId, count));
|
||||
return new Result(errorCode, new BroadMessageResult(messageId, count));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CheckUserOnlineAction extends AdminAction {
|
||||
if (inputUserId == null || !StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
sendApiMessage(inputUserId.getUserId(), ServerAPIHelper.CHECK_USER_ONLINE_REQUEST, inputUserId.getUserId().getBytes(), res -> {
|
||||
OutputCheckUserOnline out = new Gson().fromJson(new String(res), OutputCheckUserOnline.class);
|
||||
sendResponse(response, null, out);
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, out);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -53,16 +53,14 @@ public class CreateChannelAction extends AdminAction {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String channelId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateChannel(channelId));
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateChannel(channelId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,17 +53,10 @@ public class CreateChatroomAction extends AdminAction {
|
||||
}
|
||||
|
||||
WFCMessage.ChatroomInfo info = inputCreateChatroom.toChatroomInfo();
|
||||
|
||||
messagesStore.createChatroom(inputCreateChatroom.getChatroomId(), info);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateChatroom(inputCreateChatroom.getChatroomId()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok(new OutputCreateChatroom(inputCreateChatroom.getChatroomId())));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,16 +46,14 @@ public class CreateGroupAction extends AdminAction {
|
||||
byte[] data = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(data);
|
||||
String groupId = new String(data);
|
||||
sendResponse(response, null, new OutputCreateGroupResult(groupId));
|
||||
return new Result(ErrorCode.ERROR_CODE_SUCCESS, new OutputCreateGroupResult(groupId));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -78,16 +78,10 @@ public class CreateRobotAction extends AdminAction {
|
||||
if (StringUtil.isNullOrEmpty(inputCreateRobot.getSecret())) {
|
||||
inputCreateRobot.setSecret(UUIDGenerator.getUUID());
|
||||
}
|
||||
|
||||
messagesStore.addRobot(inputCreateRobot.toRobot());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateRobot(inputCreateRobot.getUserId(), inputCreateRobot.getSecret()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputCreateRobot(inputCreateRobot.getUserId(), inputCreateRobot.getSecret())));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,19 +89,13 @@ public class CreateUserAction extends AdminAction {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e, IMExceptionEvent.EventType.ADMIN_API_Exception);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR, e.getMessage());
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR, e.getMessage()));
|
||||
return true;
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputCreateUser(inputCreateUser.getUserId(), inputCreateUser.getName()));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputCreateUser(inputCreateUser.getUserId(), inputCreateUser.getName())));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,10 @@ public class DestoryChatroomAction extends AdminAction {
|
||||
InputDestoryChatroom inputDestoryChatroom = gson.fromJson(content, InputDestoryChatroom.class);
|
||||
if (inputDestoryChatroom != null
|
||||
&& !StringUtil.isNullOrEmpty(inputDestoryChatroom.getChatroomId())) {
|
||||
|
||||
messagesStore.destoryChatroom(inputDestoryChatroom.getChatroomId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(RestResult.ok());
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,24 +43,11 @@ public class DestroyUserAction extends AdminAction {
|
||||
WFCMessage.IDBuf idBuf = WFCMessage.IDBuf.newBuilder().setId(inputDestroyUser.getUserId()).build();
|
||||
sendApiMessage(inputDestroyUser.getUserId(), IMTopic.DestroyUserTopic, idBuf.toByteArray(), result -> {
|
||||
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
|
||||
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
//ba errorcode qudiao
|
||||
byte[] data = new byte[result.length -1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = result[i+1];
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode1, null);
|
||||
}
|
||||
return new Result(errorCode1);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,11 @@ public class DismissGroupAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -49,17 +49,11 @@ public class FriendRelationAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -47,9 +47,7 @@ public class FriendRelationGetAction extends AdminAction {
|
||||
list.add(data.getFriendUid());
|
||||
}
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputStringList(list));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputStringList(list)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,14 +46,9 @@ public class GetChatroomInfoAction extends AdminAction {
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-7
@@ -58,14 +58,9 @@ public class GetChatroomMembersAction extends AdminAction {
|
||||
} else {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@ public class GetGroupInfoAction extends AdminAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) {
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = messagesStore.getGroupInfo(inputGetGroup.getGroupId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (groupInfo == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -57,12 +55,9 @@ public class GetGroupInfoAction extends AdminAction {
|
||||
pojoGroupInfo.setType(groupInfo.getType());
|
||||
result = RestResult.ok(pojoGroupInfo);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ public class GetGroupMembersAction extends AdminAction {
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = messagesStore.getGroupMembers(null, inputGetGroup.getGroupId(), 0, members);
|
||||
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
@@ -69,11 +67,9 @@ public class GetGroupMembersAction extends AdminAction {
|
||||
result = RestResult.ok(out);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public class GetIMTokenAction extends AdminAction {
|
||||
}
|
||||
String token = Base64.getEncoder().encodeToString(data);
|
||||
|
||||
sendResponse(response, null, new OutputGetIMTokenData(userId, token));
|
||||
return new Result(errorCode1, new OutputGetIMTokenData(userId, token));
|
||||
} else {
|
||||
sendResponse(response, errorCode1, null);
|
||||
return new Result(errorCode1);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
||||
+2
-5
@@ -40,7 +40,6 @@ public class GetSystemSettingAction extends AdminAction {
|
||||
if (inputUserId != null) {
|
||||
SystemSettingPojo output = messagesStore.getSystemSetting(inputUserId.id);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (output == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -48,11 +47,9 @@ public class GetSystemSettingAction extends AdminAction {
|
||||
result = RestResult.ok(output);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ public class GetUserAction extends AdminAction {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -56,11 +55,9 @@ public class GetUserAction extends AdminAction {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -31,11 +31,10 @@ public class GetUserBlockListAction extends AdminAction {
|
||||
@Override
|
||||
public boolean action(Request request) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
OutputUserBlockStatusList list = new OutputUserBlockStatusList();
|
||||
list.setStatusList(messagesStore.getUserStatusList());
|
||||
RestResult result = RestResult.ok(list);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-6
@@ -39,13 +39,9 @@ public class GetUserBlockStatusAction extends AdminAction {
|
||||
&& !StringUtil.isNullOrEmpty(inputUserId.getUserId())) {
|
||||
|
||||
int status = messagesStore.getUserStatus(inputUserId.getUserId());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(new OutputUserStatus(status));
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(new OutputUserStatus(status)));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,16 +45,12 @@ public class GetUserGroupsAction extends AdminAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()))) {
|
||||
|
||||
Set<String> groupIds = messagesStore.getUserGroupIds(inputUserId.getUserId());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
OutputGroupIds outputGroupIds = new OutputGroupIds();
|
||||
outputGroupIds.setGroupIds(new ArrayList<>(groupIds));
|
||||
RestResult result = RestResult.ok(outputGroupIds);
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-8
@@ -41,17 +41,11 @@ public class KickoffGroupMemberAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-3
@@ -38,9 +38,7 @@ public class KickoffUserClientAction extends AdminAction {
|
||||
sessionsStore.kickoffUserClient(pojo.getFirst(), pojo.getSecond());
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,11 @@ public class ModifyGroupInfoAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-8
@@ -41,17 +41,11 @@ public class ModifyGroupMemberAliasAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+3
-5
@@ -45,16 +45,14 @@ public class MulticastMessageAction extends AdminAction {
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new MultiMessageResult(messageId, timestamp));
|
||||
return new Result(errorCode, new MultiMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-8
@@ -40,22 +40,16 @@ public class PutSystemSettingAction extends AdminAction {
|
||||
if (inputUserId != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.value) || !StringUtil.isNullOrEmpty(inputUserId.desc))) {
|
||||
|
||||
|
||||
boolean success = messagesStore.updateSystemSetting(inputUserId.id, inputUserId.value, inputUserId.desc);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (!success) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR);
|
||||
} else {
|
||||
result = RestResult.ok();
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,11 @@ public class QuitGroupMemberAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -44,13 +44,11 @@ public class RecallMessageAction extends AdminAction {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+2
-4
@@ -44,13 +44,11 @@ public class RecallMultiCastMessageAction extends AdminAction {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,10 +51,7 @@ public class RelationGetAction extends AdminAction {
|
||||
out.alias = data.getAlias();
|
||||
out.extra = data.getExtra();
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(out));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,16 +46,14 @@ public class SendMessageAction extends AdminAction {
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new SendMessageResult(messageId, timestamp));
|
||||
return new Result(errorCode, new SendMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
return new Result(errorCode);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-3
@@ -38,9 +38,7 @@ public class SensitiveWordAddAction extends AdminAction {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
sendResponse(response, errorCode, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -39,9 +39,7 @@ public class SensitiveWordDeleteAction extends AdminAction {
|
||||
|
||||
sendResponse(response, errorCode, null);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,17 +41,11 @@ public class SetGroupManagerAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -41,17 +41,11 @@ public class TransferGroupAction extends AdminAction {
|
||||
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 new Result(errorCode);
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -50,13 +50,9 @@ public class UpdateUserAction extends AdminAction {
|
||||
&& inputCreateUser.flag > 0) {
|
||||
|
||||
ErrorCode errorCode = messagesStore.updateUserInfo(inputCreateUser.userInfo, inputCreateUser.flag);
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(errorCode));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ public class GetChannelAction extends ChannelAction {
|
||||
@Override
|
||||
public boolean action(Request request) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(OutputGetChannelInfo.fromPbInfo(channelInfo));
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(OutputGetChannelInfo.fromPbInfo(channelInfo)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-4
@@ -36,10 +36,7 @@ public class GetChannelSubscribersAction extends ChannelAction {
|
||||
OutputStringList outputStringList = new OutputStringList();
|
||||
outputStringList.setList(new ArrayList<>());
|
||||
outputStringList.getList().addAll(messagesStore.getChannelSubscriber(channelInfo.getTargetId()));
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(outputStringList);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(outputStringList));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ public class GetUserAction extends ChannelAction {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
|
||||
if (user == null || StringUtil.isNullOrEmpty(user.getName())) {
|
||||
@@ -70,11 +69,9 @@ public class GetUserAction extends ChannelAction {
|
||||
}
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -45,9 +45,7 @@ public class ModifyChannelProfileAction extends ChannelAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,9 +65,7 @@ public class SendMessageAction extends ChannelAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-3
@@ -54,9 +54,7 @@ public class SubscriberChannelAction extends ChannelAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ public class AddGroupMemberAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -60,9 +60,7 @@ public class CreateGroupAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -32,9 +32,7 @@ public class DeleteCallbackAction extends RobotAction {
|
||||
robot = robot.toBuilder().clearCallback().setState(0).build();
|
||||
messagesStore.addRobot(robot);
|
||||
}
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ public class DismissGroupAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -33,9 +33,7 @@ public class GetCallbackAction extends RobotAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
RobotCallbackPojo out = new RobotCallbackPojo();
|
||||
out.setUrl(robot.getCallback());
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok(out);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok(out));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ public class GetGroupInfoAction extends RobotAction {
|
||||
&& (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) {
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = messagesStore.getGroupInfo(inputGetGroup.getGroupId());
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (groupInfo == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
@@ -56,12 +54,9 @@ public class GetGroupInfoAction extends RobotAction {
|
||||
pojoGroupInfo.setType(groupInfo.getType());
|
||||
result = RestResult.ok(pojoGroupInfo);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
|
||||
List<WFCMessage.GroupMember> members = new ArrayList<>();
|
||||
ErrorCode errorCode = messagesStore.getGroupMembers(null, inputGetGroup.getGroupId(), 0, members);
|
||||
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
@@ -77,11 +74,9 @@ public class GetGroupMembersAction extends RobotAction {
|
||||
result = RestResult.ok(out);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,19 +43,15 @@ public class GetUserAction extends RobotAction {
|
||||
user = messagesStore.getUserInfoByMobile(inputUserId.getMobile());
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (user == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -51,9 +51,7 @@ public class KickoffGroupMemberAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,9 +51,7 @@ public class ModifyGroupInfoAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-3
@@ -51,9 +51,7 @@ public class ModifyGroupMemberAliasAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,9 +51,7 @@ public class QuitGroupMemberAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -54,9 +54,7 @@ public class SendMessageAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -35,14 +35,9 @@ public class SetCallbackAction extends RobotAction {
|
||||
robot = robot.toBuilder().setCallback(input.getUrl()).setState(1).build();
|
||||
messagesStore.addRobot(robot);
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.ok());
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ public class TransferGroupAction extends RobotAction {
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -76,7 +76,6 @@ public class UpdateProfileAction extends RobotAction {
|
||||
break;
|
||||
}
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.ok();
|
||||
if(modified) {
|
||||
try {
|
||||
@@ -86,8 +85,7 @@ public class UpdateProfileAction extends RobotAction {
|
||||
result.setErrorCode(ErrorCode.ERROR_CODE_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
setResponseContent(result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user