修改重构引入的部分问题

This commit is contained in:
imhao183
2021-04-23 10:22:50 +08:00
parent 49fcc73f78
commit d99e9a079d
8 changed files with 27 additions and 28 deletions
@@ -46,7 +46,7 @@ public class AddFriendRequestAction extends AdminAction {
byteBuf.writeBytes(result);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
return new Result(errorCode);
});
}, !input.isForce());
return false;
}
return true;
@@ -92,9 +92,16 @@ abstract public class AdminAction extends Action {
response.setContent(new Gson().toJson(result));
response.send();
}
protected void sendApiMessage(String fromUser, String topic, byte[] message, ApiCallback callback) {
ServerAPIHelper.sendRequest(fromUser, null, topic, message, new ServerAPIHelper.Callback() {
sendApiMessage(fromUser, null, topic, message, callback, false);
}
protected void sendApiMessage(String fromUser, String topic, byte[] message, ApiCallback callback, boolean noAdmin) {
sendApiMessage(fromUser, null, topic, message, callback, noAdmin);
}
protected void sendApiMessage(String fromUser, String clientId, String topic, byte[] message, ApiCallback callback, boolean noAdmin) {
ServerAPIHelper.sendRequest(fromUser, clientId, topic, message, new ServerAPIHelper.Callback() {
@Override
public void onSuccess(byte[] result) {
if(callback != null) {
@@ -119,6 +126,6 @@ abstract public class AdminAction extends Action {
ctx.executor().execute(command);
};
}
}, true);
}, !noAdmin);
}
}
@@ -38,7 +38,7 @@ public class GetIMTokenAction extends AdminAction {
WFCMessage.GetTokenRequest getTokenRequest = WFCMessage.GetTokenRequest.newBuilder().setUserId(userId).setClientId(input.getClientId()).setPlatform(input.getPlatform() == null ? 0 : input.getPlatform()).build();
sendApiMessage(userId, IMTopic.GetTokenTopic, getTokenRequest.toByteArray(), result -> {
sendApiMessage(userId, input.getClientId(), IMTopic.GetTokenTopic, getTokenRequest.toByteArray(), result -> {
ErrorCode errorCode1 = ErrorCode.fromCode(result[0]);
if (errorCode1 == ErrorCode.ERROR_CODE_SUCCESS) {
//ba errorcode qudiao
@@ -52,7 +52,7 @@ public class GetIMTokenAction extends AdminAction {
} else {
return new Result(errorCode1);
}
});
}, false);
return false;
}
return true;
@@ -116,7 +116,10 @@ abstract public class ChannelAction extends Action {
}
protected void sendApiMessage(String topic, byte[] message, Callback callback) {
ServerAPIHelper.sendRequest(channelInfo.getOwner(), null, topic, message, new ServerAPIHelper.Callback() {
sendApiMessage(channelInfo.getOwner(), topic, message, callback);
}
protected void sendApiMessage(String user, String topic, byte[] message, Callback callback) {
ServerAPIHelper.sendRequest(user, null, topic, message, new ServerAPIHelper.Callback() {
@Override
public void onSuccess(byte[] response) {
callback.onSuccess(response);
@@ -19,7 +19,6 @@ 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;
@@ -34,7 +33,7 @@ public class SubscriberChannelAction extends ChannelAction {
public boolean action(Request request) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputChannelSubscribe input = getRequestBody(request.getNettyRequest(), InputChannelSubscribe.class);
if (input != null && !StringUtil.isNullOrEmpty(input.getTarget())) {
if (input != null && !StringUtil.isNullOrEmpty(input.getUserId())) {
if(input.getSubscribe() > 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Active_Subscribe) == 0) {
response.setStatus(HttpResponseStatus.OK);
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT);
@@ -42,7 +41,7 @@ public class SubscriberChannelAction extends ChannelAction {
return true;
}
WFCMessage.ListenChannel listenChannel = WFCMessage.ListenChannel.newBuilder().setChannelId(channelInfo.getTargetId()).setListen(input.getSubscribe()).build();
sendApiMessage(IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
sendApiMessage(input.getUserId(), IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeBytes(result);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());