Explorar el Código

消息体添加昵称头像字段

779513719 hace 4 años
padre
commit
3f5387cff9

+ 25 - 0
jim-common/src/main/java/org/jim/common/packets/ChatBody.java

@@ -38,6 +38,31 @@ public class ChatBody extends Message {
 	 */
 	private String group_id;
 
+	/**
+	 * user nick
+	 */
+	private String nick;
+	/**
+	 * 用户头像
+	 */
+	private String avatar;
+
+	public String getNick() {
+		return nick;
+	}
+
+	public void setNick(String nick) {
+		this.nick = nick;
+	}
+
+	public String getAvatar() {
+		return avatar;
+	}
+
+	public void setAvatar(String avatar) {
+		this.avatar = avatar;
+	}
+
 	private ChatBody(){}
 	
 	private ChatBody(String id , String from , String to , Integer msgType , Integer chatType , String content , String group_id , Integer cmd , Long createTime , JSONObject extras){

+ 6 - 4
jim-server/src/main/java/org/jim/server/command/handler/ChatReqHandler.java

@@ -5,10 +5,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.jim.common.ImAio;
 import org.jim.common.ImConst;
 import org.jim.common.ImPacket;
-import org.jim.common.packets.ChatBody;
-import org.jim.common.packets.ChatType;
-import org.jim.common.packets.Command;
-import org.jim.common.packets.RespBody;
+import org.jim.common.packets.*;
 import org.jim.common.utils.ChatKit;
 import org.jim.server.command.AbstractCmdHandler;
 import org.jim.server.command.handler.processor.chat.ChatCmdProcessor;
@@ -73,6 +70,11 @@ public class ChatReqHandler extends AbstractCmdHandler {
 			msgQueueRunnable.addMsg(packet);
 			msgQueueRunnable.getExecutor().execute(msgQueueRunnable);
 		}
+		User user = ImAio.getUser(chatBody.getFrom());
+		if (user != null){
+			chatBody.setAvatar(user.getAvatar());
+			chatBody.setNick(user.getNick());
+		}
 		ImPacket chatPacket = new ImPacket(Command.COMMAND_CHAT_REQ,new RespBody(Command.COMMAND_CHAT_REQ,chatBody).toByte());
 		//设置同步序列号;
 		chatPacket.setSynSeq(packet.getSynSeq());