|
|
@@ -7,13 +7,17 @@ import com.x.base.core.entity.JpaObject;
|
|
|
import com.x.base.core.entity.annotation.CheckPersistType;
|
|
|
import com.x.base.core.project.bean.WrapCopier;
|
|
|
import com.x.base.core.project.bean.WrapCopierFactory;
|
|
|
+import com.x.base.core.project.config.Config;
|
|
|
import com.x.base.core.project.http.ActionResult;
|
|
|
import com.x.base.core.project.http.EffectivePerson;
|
|
|
import com.x.base.core.project.logger.Logger;
|
|
|
import com.x.base.core.project.logger.LoggerFactory;
|
|
|
import com.x.base.core.project.message.MessageConnector;
|
|
|
+import com.x.message.assemble.communicate.ThisApplication;
|
|
|
+import com.x.message.assemble.communicate.ws.collaboration.ActionCollaboration;
|
|
|
import com.x.message.core.entity.IMConversation;
|
|
|
import com.x.message.core.entity.IMMsg;
|
|
|
+import com.x.message.core.entity.Message;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -62,8 +66,30 @@ public class ActionMsgCreate extends BaseAction {
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e);
|
|
|
}
|
|
|
- logger.info("发送im消息, person: " + persons.get(i));
|
|
|
- MessageConnector.send(MessageConnector.TYPE_IM_CREATE, "来自 "+ name + " 的消息", persons.get(i), msg);
|
|
|
+ String person = persons.get(i);
|
|
|
+ logger.info("发送im消息, person: " + person);
|
|
|
+ String title = "来自 "+ name + " 的消息";
|
|
|
+ MessageConnector.send(MessageConnector.TYPE_IM_CREATE, title, person, msg);
|
|
|
+ //如果消息接收者没有在线 连接ws 就发送一个推送消息
|
|
|
+ try {
|
|
|
+ if (!ActionCollaboration.clients.values().contains(person)) {
|
|
|
+ logger.info("向app 推送im消息, person: " + person);
|
|
|
+ Message message = new Message();
|
|
|
+ String body = imMessageBody(msg);
|
|
|
+ message.setTitle(title + ": " + body);
|
|
|
+ message.setPerson(person);
|
|
|
+ message.setType(MessageConnector.TYPE_IM_CREATE);
|
|
|
+ message.setId("");
|
|
|
+ if (Config.communicate().pmsEnable()) {
|
|
|
+ ThisApplication.pmsConsumeQueue.send(message);
|
|
|
+ }
|
|
|
+ if (Config.pushConfig().getEnable()) {
|
|
|
+ ThisApplication.pmsInnerConsumeQueue.send(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ActionResult<Wo> result = new ActionResult<>();
|
|
|
@@ -73,6 +99,16 @@ public class ActionMsgCreate extends BaseAction {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String imMessageBody(IMMsg msg) {
|
|
|
+ String json = msg.getBody();
|
|
|
+ IMMessageBody body = gson.fromJson(json, IMMessageBody.class);
|
|
|
+ if ("emoji".equals(body.getType())) {
|
|
|
+ return "[表情]";
|
|
|
+ }else {
|
|
|
+ return body.getBody();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
public static class Wo extends IMMsg {
|
|
|
@@ -82,5 +118,26 @@ public class ActionMsgCreate extends BaseAction {
|
|
|
JpaObject.FieldsInvisible);
|
|
|
}
|
|
|
|
|
|
+ public static class IMMessageBody {
|
|
|
+ private String type;
|
|
|
+ private String body;
|
|
|
+
|
|
|
+ public String getType() {
|
|
|
+ return type;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setType(String type) {
|
|
|
+ this.type = type;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBody() {
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setBody(String body) {
|
|
|
+ this.body = body;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|