revert对api参数的修改,需要保持SDK的兼容

This commit is contained in:
imhao183
2021-04-23 10:27:48 +08:00
parent d99e9a079d
commit 2ced517f70
3 changed files with 10 additions and 10 deletions
@@ -33,7 +33,7 @@ public class SubscriberChannelAction extends ChannelAction {
public boolean action(Request request) { public boolean action(Request request) {
if (request.getNettyRequest() instanceof FullHttpRequest) { if (request.getNettyRequest() instanceof FullHttpRequest) {
InputChannelSubscribe input = getRequestBody(request.getNettyRequest(), InputChannelSubscribe.class); InputChannelSubscribe input = getRequestBody(request.getNettyRequest(), InputChannelSubscribe.class);
if (input != null && !StringUtil.isNullOrEmpty(input.getUserId())) { if (input != null && !StringUtil.isNullOrEmpty(input.getTarget())) {
if(input.getSubscribe() > 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Active_Subscribe) == 0) { if(input.getSubscribe() > 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Active_Subscribe) == 0) {
response.setStatus(HttpResponseStatus.OK); response.setStatus(HttpResponseStatus.OK);
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT); RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT);
@@ -41,7 +41,7 @@ public class SubscriberChannelAction extends ChannelAction {
return true; return true;
} }
WFCMessage.ListenChannel listenChannel = WFCMessage.ListenChannel.newBuilder().setChannelId(channelInfo.getTargetId()).setListen(input.getSubscribe()).build(); WFCMessage.ListenChannel listenChannel = WFCMessage.ListenChannel.newBuilder().setChannelId(channelInfo.getTargetId()).setListen(input.getSubscribe()).build();
sendApiMessage(input.getUserId(), IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> { sendApiMessage(input.getTarget(), IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
ByteBuf byteBuf = Unpooled.buffer(); ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeBytes(result); byteBuf.writeBytes(result);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte()); ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
@@ -9,15 +9,15 @@
package cn.wildfirechat.pojos; package cn.wildfirechat.pojos;
public class InputChannelSubscribe { public class InputChannelSubscribe {
private String userId; private String target;
private int subscribe; //1,订阅;0,取消订阅 private int subscribe; //1,订阅;0,取消订阅
public String getUserId() { public String getTarget() {
return userId; return target;
} }
public void setUserId(String userId) { public void setTarget(String target) {
this.userId = userId; this.target = target;
} }
public int getSubscribe() { public int getSubscribe() {
@@ -55,10 +55,10 @@ public class ChannelServiceApi {
return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class); return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
} }
public IMResult<Void> subscribe(String target) throws Exception { public IMResult<Void> subscribe(String userId) throws Exception {
String path = APIPath.Channel_Subscribe; String path = APIPath.Channel_Subscribe;
InputChannelSubscribe input = new InputChannelSubscribe(); InputChannelSubscribe input = new InputChannelSubscribe();
input.setUserId(target); input.setTarget(userId);
input.setSubscribe(1); input.setSubscribe(1);
return httpUtils.httpJsonPost(path, input, Void.class); return httpUtils.httpJsonPost(path, input, Void.class);
} }
@@ -66,7 +66,7 @@ public class ChannelServiceApi {
public IMResult<Void> unsubscribe(String userId) throws Exception { public IMResult<Void> unsubscribe(String userId) throws Exception {
String path = APIPath.Channel_Subscribe; String path = APIPath.Channel_Subscribe;
InputChannelSubscribe input = new InputChannelSubscribe(); InputChannelSubscribe input = new InputChannelSubscribe();
input.setUserId(userId); input.setTarget(userId);
input.setSubscribe(0); input.setSubscribe(0);
return httpUtils.httpJsonPost(path, input, Void.class); return httpUtils.httpJsonPost(path, input, Void.class);
} }