Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5f64df2de | ||
|
|
c7f1ea57dc | ||
|
|
c9b2de076d | ||
|
|
552fadaa87 | ||
|
|
765572db36 | ||
|
|
a5f194b385 | ||
|
|
c74cd7e290 | ||
|
|
70cf65f0c0 |
@@ -193,8 +193,8 @@ friend.disable_search false
|
|||||||
##禁止按照昵称搜索用户。
|
##禁止按照昵称搜索用户。
|
||||||
friend.disable_nick_name_search false
|
friend.disable_nick_name_search false
|
||||||
|
|
||||||
##禁止按照用户id搜索用户,默认为true。
|
##禁止按照用户id搜索用户,默认为false。
|
||||||
friend.disable_user_id_search true
|
friend.disable_user_id_search false
|
||||||
|
|
||||||
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
||||||
friend.disable_friend_request false
|
friend.disable_friend_request false
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `t_user_session` ADD COLUMN `_ip` varchar(40) DEFAULT '';
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `t_user_session` ADD COLUMN `_ip` varchar(40) DEFAULT '';
|
||||||
+1
-55
@@ -5,7 +5,7 @@
|
|||||||
<relativePath>../</relativePath>
|
<relativePath>../</relativePath>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.9</version>
|
<version>1.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
@@ -211,60 +211,6 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<includes>
|
|
||||||
<include>**/*Test.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Generate the test-jar -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>test-jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Includes to generate OSGi headers -->
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>test-jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.felix</groupId>
|
|
||||||
<artifactId>maven-bundle-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>bundle-manifest</id>
|
|
||||||
<phase>process-classes</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>manifest</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>pl.project13.maven</groupId>
|
<groupId>pl.project13.maven</groupId>
|
||||||
<artifactId>git-commit-id-plugin</artifactId>
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package com.xiaoleilu.loServer.action;
|
|||||||
import cn.wildfirechat.proto.ProtoConstants;
|
import cn.wildfirechat.proto.ProtoConstants;
|
||||||
import cn.wildfirechat.proto.WFCMessage;
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
import com.hazelcast.util.StringUtil;
|
||||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
import com.xiaoleilu.loServer.annotation.Route;
|
import com.xiaoleilu.loServer.annotation.Route;
|
||||||
import com.xiaoleilu.loServer.handler.Request;
|
import com.xiaoleilu.loServer.handler.Request;
|
||||||
@@ -28,7 +29,9 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import cn.wildfirechat.common.ErrorCode;
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@Route("/route")
|
@Route("/route")
|
||||||
@@ -111,6 +114,12 @@ public class RouteAction extends Action {
|
|||||||
WFCMessage.IMHttpWrapper wrapper = WFCMessage.IMHttpWrapper.parseFrom(bytes);
|
WFCMessage.IMHttpWrapper wrapper = WFCMessage.IMHttpWrapper.parseFrom(bytes);
|
||||||
String token = wrapper.getToken();
|
String token = wrapper.getToken();
|
||||||
String userId = Tokenor.getUserId(token.getBytes());
|
String userId = Tokenor.getUserId(token.getBytes());
|
||||||
|
|
||||||
|
String remote = ((InetSocketAddress) ctx.channel().remoteAddress())
|
||||||
|
.getAddress().getHostAddress();
|
||||||
|
String ip = computeRealIp(request.getHeaders(), remote);
|
||||||
|
|
||||||
|
|
||||||
LOG.info("RouteAction token={}, userId={}", token, userId);
|
LOG.info("RouteAction token={}, userId={}", token, userId);
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
sendResponse(response, ErrorCode.ERROR_CODE_TOKEN_ERROR, null);
|
sendResponse(response, ErrorCode.ERROR_CODE_TOKEN_ERROR, null);
|
||||||
@@ -119,6 +128,8 @@ public class RouteAction extends Action {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(byte[] result) {
|
public void onSuccess(byte[] result) {
|
||||||
sendResponse(response, null, result);
|
sendResponse(response, null, result);
|
||||||
|
//save ip after success response.
|
||||||
|
sessionsStore.updateSessionIp(userId, wrapper.getClientId(), ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,6 +158,20 @@ public class RouteAction extends Action {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String computeRealIp(Map<String, String> h, String remote) {
|
||||||
|
String xff = h.get("X-Forwarded-For");
|
||||||
|
if (xff != null && !xff.isEmpty() && !"unknown".equalsIgnoreCase(xff)) {
|
||||||
|
int idx = xff.indexOf(',');
|
||||||
|
String first = (idx > 0 ? xff.substring(0, idx) : xff).trim();
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
String xri = h.get("X-Real-IP");
|
||||||
|
if (xri != null && !xri.isEmpty() && !"unknown".equalsIgnoreCase(xri)) {
|
||||||
|
return xri;
|
||||||
|
}
|
||||||
|
return remote;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents) {
|
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents) {
|
||||||
response.setStatus(HttpResponseStatus.OK);
|
response.setStatus(HttpResponseStatus.OK);
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
|
|||||||
@@ -1832,6 +1832,31 @@ public class DatabaseStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateSessionIp(String uid, String cid, String ip) {
|
||||||
|
mScheduler.execute(()->{
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
connection = DBUtil.getConnection();
|
||||||
|
String sql = "update t_user_session set _ip = ? where `_uid` = ? and `_cid` = ?";
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
int index = 1;
|
||||||
|
statement.setString(index++, ip);
|
||||||
|
statement.setString(index++, uid);
|
||||||
|
statement.setString(index++, cid);
|
||||||
|
|
||||||
|
int c = statement.executeUpdate();
|
||||||
|
LOG.info("Update rows {}", c);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||||
|
} finally {
|
||||||
|
DBUtil.closeDB(connection, statement);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void clearMultiEndpoint(String uid, String clientId, int platform) {
|
void clearMultiEndpoint(String uid, String clientId, int platform) {
|
||||||
LOG.info("clearMultiEndpoint {}, {}", uid, clientId);
|
LOG.info("clearMultiEndpoint {}, {}", uid, clientId);
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
printMissConfigLog(FRIEND_Disable_NickName_Search, mDisableNicknameSearch + "");
|
printMissConfigLog(FRIEND_Disable_NickName_Search, mDisableNicknameSearch + "");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mDisableUserIdSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_UserId_Search, "true"));
|
mDisableUserIdSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_UserId_Search, "false"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
private int deleted;
|
private int deleted;
|
||||||
|
|
||||||
private boolean pullHistoryMsg;
|
private boolean pullHistoryMsg;
|
||||||
|
private String ip;
|
||||||
|
|
||||||
public int getDeleted() {
|
public int getDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
@@ -159,6 +160,14 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
private int pushType;
|
private int pushType;
|
||||||
private int platform;
|
private int platform;
|
||||||
|
|
||||||
@@ -544,6 +553,15 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
return session.clientSession;
|
return session.clientSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSessionIp(String username, String clientID, String ip) {
|
||||||
|
Session session = getSession(clientID);
|
||||||
|
if(session != null && session.getDeleted() == 0) {
|
||||||
|
session.setIp(ip);
|
||||||
|
databaseStore.updateSessionIp(username, clientID, ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Session sessionForClientAndUser(String username, String clientID) {
|
public Session sessionForClientAndUser(String username, String clientID) {
|
||||||
Session session = sessions.get(clientID);
|
Session session = sessions.get(clientID);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public interface ISessionsStore {
|
|||||||
ErrorCode loadActiveSession(String username, String clientID);
|
ErrorCode loadActiveSession(String username, String clientID);
|
||||||
|
|
||||||
ClientSession updateExistSession(String username, String clientID, WFCMessage.RouteRequest endpoint, boolean cleanSession);
|
ClientSession updateExistSession(String username, String clientID, WFCMessage.RouteRequest endpoint, boolean cleanSession);
|
||||||
|
void updateSessionIp(String username, String clientID, String ip);
|
||||||
Session getSession(String clientID);
|
Session getSession(String clientID);
|
||||||
|
|
||||||
void cleanDuplatedToken(String cid, int pushType, String token, boolean isVoip, String packageName);
|
void cleanDuplatedToken(String cid, int pushType, String token, boolean isVoip, String packageName);
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ public class ProtocolProcessor {
|
|||||||
sessionstatus = 0;
|
sessionstatus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
userOnlineStatus.sessions.add(new OutputCheckUserOnline.Session(userId, session.getClientID(), session.getPlatform(), sessionstatus, session.getLastActiveTime(), session.getAppName()));
|
userOnlineStatus.sessions.add(new OutputCheckUserOnline.Session(userId, session.getClientID(), session.getPlatform(), sessionstatus, session.getLastActiveTime(), session.getAppName(), session.getIp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpUtils.httpJsonPost(mUserOnlineStatusCallback, GsonUtil.gson.toJson(userOnlineStatus), HttpUtils.HttpPostType.POST_TYPE_User_Online_Event_Callback);
|
HttpUtils.httpJsonPost(mUserOnlineStatusCallback, GsonUtil.gson.toJson(userOnlineStatus), HttpUtils.HttpPostType.POST_TYPE_User_Online_Event_Callback);
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class Qos1PublishHandler extends QosPublishHandler {
|
|||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.addSession(userId, session.getClientID(), session.getPlatform(), status, session.getLastActiveTime(), session.getAppName());
|
out.addSession(userId, session.getClientID(), session.getPlatform(), status, session.getLastActiveTime(), session.getAppName(), session.getIp());
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onRouteHandled(GsonUtil.gson.toJson(out).getBytes());
|
callback.onRouteHandled(GsonUtil.gson.toJson(out).getBytes());
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.9</version>
|
<version>1.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -20,22 +20,24 @@ public class OutputCheckUserOnline {
|
|||||||
public int status; //0 online, 1 have session offline
|
public int status; //0 online, 1 have session offline
|
||||||
public long lastSeen;
|
public long lastSeen;
|
||||||
public String packageName;
|
public String packageName;
|
||||||
|
public String ip;
|
||||||
|
|
||||||
public Session() {
|
public Session() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session(String clientId, String userId, int platform, int status, long lastSeen, String packageName) {
|
public Session(String clientId, String userId, int platform, int status, long lastSeen, String packageName, String ip) {
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.lastSeen = lastSeen;
|
this.lastSeen = lastSeen;
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSession(String userId, String clientId, int platform, int status, long lastSeen, String packageName) {
|
public void addSession(String userId, String clientId, int platform, int status, long lastSeen, String packageName, String ip) {
|
||||||
Session session = new Session(clientId, userId, platform, status, lastSeen, packageName);
|
Session session = new Session(clientId, userId, platform, status, lastSeen, packageName, ip);
|
||||||
sessions.add(session);
|
sessions.add(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<!--<relativePath>../pom.xml</relativePath>-->
|
<!--<relativePath>../pom.xml</relativePath>-->
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.9</version>
|
<version>1.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -190,8 +190,8 @@ friend.disable_search false
|
|||||||
##禁止按照昵称搜索用户。
|
##禁止按照昵称搜索用户。
|
||||||
friend.disable_nick_name_search false
|
friend.disable_nick_name_search false
|
||||||
|
|
||||||
##禁止按照用户id搜索用户,默认为true。
|
##禁止按照用户id搜索用户,默认为false。
|
||||||
friend.disable_user_id_search true
|
friend.disable_user_id_search false
|
||||||
|
|
||||||
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
##禁止发送好友邀请,通过server api添加好友不受此限制(force参数需要为true)
|
||||||
friend.disable_friend_request false
|
friend.disable_friend_request false
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.3.9</version>
|
<version>1.4.0</version>
|
||||||
<name>Wildfire Chat</name>
|
<name>Wildfire Chat</name>
|
||||||
<description>Wildfire Chat Server</description>
|
<description>Wildfire Chat Server</description>
|
||||||
<inceptionYear>2019</inceptionYear>
|
<inceptionYear>2019</inceptionYear>
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
11. *** 1.3.8版本添加了server api发送消息的限制,限制消息体最大内容不能超过64KB,如果升级请注意业务系统发送消息大小。***
|
11. *** 1.3.8版本添加了server api发送消息的限制,限制消息体最大内容不能超过64KB,如果升级请注意业务系统发送消息大小。***
|
||||||
|
|
||||||
# 更新记录
|
# 更新记录
|
||||||
|
--------------
|
||||||
|
Release note 1.4.0:
|
||||||
|
1. 添加对用户IP来源的记录。
|
||||||
|
2. 移除无用的plugin,可以在java8环境下编译通过。
|
||||||
|
3. Server SDK解决某些Java版本下消息没有注册的问题。
|
||||||
|
4. Server SDK解决解析图片缩略图不存在的错误问题。
|
||||||
|
5. Server SDK解决发送带引用的消息客户端无法解析的问题。
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
Release note 1.3.9:
|
Release note 1.3.9:
|
||||||
1. 解决server sdk反复初始化内存泄漏的问题。
|
1. 解决server sdk反复初始化内存泄漏的问题。
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>1.3.9</version>
|
<version>1.4.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import static cn.wildfirechat.proto.ProtoConstants.ChannelState.*;
|
|||||||
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static boolean commercialServer = true;
|
private static boolean commercialServer = false;
|
||||||
private static boolean advanceVoip = false;
|
private static boolean advanceVoip = false;
|
||||||
private static boolean robotMomentsEnabled = false;
|
private static boolean robotMomentsEnabled = false;
|
||||||
private static boolean momentsEnabled = false;
|
private static boolean momentsEnabled = false;
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ public class ImageMessageContent extends MediaMessageContent {
|
|||||||
public MessagePayload encode() {
|
public MessagePayload encode() {
|
||||||
MessagePayload payload = super.encode();
|
MessagePayload payload = super.encode();
|
||||||
payload.setSearchableContent("[图片]");
|
payload.setSearchableContent("[图片]");
|
||||||
payload.setBase64edData(Base64.getEncoder().encodeToString(thumbnailBytes));
|
if(thumbnailBytes != null) {
|
||||||
|
payload.setBase64edData(Base64.getEncoder().encodeToString(thumbnailBytes));
|
||||||
|
}
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
@@ -45,7 +47,9 @@ public class ImageMessageContent extends MediaMessageContent {
|
|||||||
@Override
|
@Override
|
||||||
public void decode(MessagePayload payload) {
|
public void decode(MessagePayload payload) {
|
||||||
super.decode(payload);
|
super.decode(payload);
|
||||||
thumbnailBytes = Base64.getDecoder().decode(payload.getBase64edData());
|
if(payload.getBase64edData() != null) {
|
||||||
|
thumbnailBytes = Base64.getDecoder().decode(payload.getBase64edData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,12 +8,39 @@ import cn.wildfirechat.sdk.utilities.ClassUtil;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class MessageContentFactory {
|
public class MessageContentFactory {
|
||||||
private static final Map<Integer, Class<? extends MessageContent>> contentClassMap = new ConcurrentHashMap<>();
|
private static final Map<Integer, Class<? extends MessageContent>> contentClassMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private static List<Class> buildinMessageContents = Arrays.asList(
|
||||||
|
ArticlesMessageContent.class,
|
||||||
|
StreamTextGeneratedMessageContent.class,
|
||||||
|
CallStartMessageContent.class,
|
||||||
|
StreamTextGeneratingMessageContent.class,
|
||||||
|
CardMessageContent.class,
|
||||||
|
MultiCallOngoingMessageContent.class,
|
||||||
|
TextMessageContent.class,
|
||||||
|
DeleteMessageContent.class,
|
||||||
|
NotDeliveredMessageContent.class,
|
||||||
|
TipNotificationMessageContent.class,
|
||||||
|
FileMessageContent.class,
|
||||||
|
PTTSoundMessageContent.class,
|
||||||
|
TypingMessageContent.class,
|
||||||
|
ImageMessageContent.class,
|
||||||
|
RecallMessageContent.class,
|
||||||
|
UnknownMessageContent.class,
|
||||||
|
LinkMessageContent.class,
|
||||||
|
RichNotificationMessageContent.class,
|
||||||
|
VideoMessageContent.class,
|
||||||
|
LocationMessageContent.class,
|
||||||
|
SoundMessageContent.class,
|
||||||
|
StickerMessageContent.class
|
||||||
|
);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
registerAllMessageContent();
|
registerAllMessageContent();
|
||||||
}
|
}
|
||||||
@@ -59,6 +86,15 @@ public class MessageContentFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void registerAllMessageContent() {
|
private static void registerAllMessageContent() {
|
||||||
|
try {
|
||||||
|
for (Class buildinMessageContent : buildinMessageContents) {
|
||||||
|
MessageContent content = (MessageContent)buildinMessageContent.newInstance();
|
||||||
|
contentClassMap.put(content.getContentType(), buildinMessageContent);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Class cls : ClassUtil.getAllAssignedClass(MessageContent.class)) {
|
for (Class cls : ClassUtil.getAllAssignedClass(MessageContent.class)) {
|
||||||
if(!Modifier.isAbstract(cls.getModifiers())) {
|
if(!Modifier.isAbstract(cls.getModifiers())) {
|
||||||
|
|||||||
@@ -50,13 +50,18 @@ public class QuoteInfo {
|
|||||||
object.put("i", userId);
|
object.put("i", userId);
|
||||||
object.put("n", userDisplayName);
|
object.put("n", userDisplayName);
|
||||||
object.put("d", messageDigest);
|
object.put("d", messageDigest);
|
||||||
return object;
|
JSONObject quote = new JSONObject();
|
||||||
|
quote.put("quote", object);
|
||||||
|
return quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decode(JSONObject object) {
|
public void decode(JSONObject object) {
|
||||||
messageUid = (long) object.get("u");
|
JSONObject quote = (JSONObject)object.get("quote");
|
||||||
userId = (String) object.get("i");
|
if(quote != null) {
|
||||||
userDisplayName = (String) object.get("n");
|
messageUid = (long) quote.get("u");
|
||||||
messageDigest = (String) object.get("d");
|
userId = (String) quote.get("i");
|
||||||
|
userDisplayName = (String) quote.get("n");
|
||||||
|
messageDigest = (String) quote.get("d");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user