提交 1c63ef77 编写于 作者: F fancy

IM聊天增加删除会话功能

上级 9114652e
package com.x.message.assemble.communicate.factory;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
......@@ -42,21 +43,6 @@ public class IMConversationFactory extends AbstractFactory {
return em.createQuery(cq).getResultList();
}
/**
* 获取成员包含person的会话id 列表
* @param person
* @return
* @throws Exception
*/
public List<String> listConversationIdListWithPerson(String person) throws Exception {
EntityManager em = this.entityManagerContainer().get(IMConversation.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<IMConversation> root = cq.from(IMConversation.class);
Predicate p = cb.isMember(person, root.get(IMConversation_.personList));
cq.select(root.get(IMConversation_.id)).where(p);
return em.createQuery(cq).getResultList();
}
/**
* 获取成员包含person的会话id 列表
......@@ -138,7 +124,8 @@ public class IMConversationFactory extends AbstractFactory {
}
/**
* 分页查询会话中的聊天消息
* 查询会话中的聊天消息
* 分页查询需要
* @param adjustPage
* @param adjustPageSize
* @param conversationId
......@@ -146,17 +133,41 @@ public class IMConversationFactory extends AbstractFactory {
* @throws Exception
*/
public List<IMMsg> listMsgWithConversationByPage(Integer adjustPage,
Integer adjustPageSize, String conversationId) throws Exception {
Integer adjustPageSize, String conversationId, Date lastDeleteTime) throws Exception {
EntityManager em = this.entityManagerContainer().get(IMMsg.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<IMMsg> cq = cb.createQuery(IMMsg.class);
Root<IMMsg> root = cq.from(IMMsg.class);
Predicate p = cb.equal(root.get(IMMsg_.conversationId), conversationId);
if (lastDeleteTime != null) {
p = cb.and(p, cb.greaterThan(root.get(IMMsg_.createTime),lastDeleteTime));
}
cq.select(root).where(p).orderBy(cb.desc(root.get(IMMsg_.createTime)));
return em.createQuery(cq).setFirstResult((adjustPage - 1) * adjustPageSize).setMaxResults(adjustPageSize)
.getResultList();
}
/**
* 查询会话聊天消息总数
* 分页查询需要
* @param conversationId
* @return
* @throws Exception
*/
public Long count(String conversationId, Date lastDeleteTime) throws Exception {
EntityManager em = this.entityManagerContainer().get(IMMsg.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<IMMsg> root = cq.from(IMMsg.class);
Predicate p = cb.equal(root.get(IMMsg_.conversationId), conversationId);
if (lastDeleteTime != null) {
p = cb.and(p, cb.greaterThan(root.get(IMMsg_.createTime),lastDeleteTime));
}
return em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
}
/**
* 根据会话id查询所有的消息id
* 清空聊天记录用
......@@ -174,18 +185,18 @@ public class IMConversationFactory extends AbstractFactory {
}
/**
* 查询会话聊天消息总数
* 分页查询需要
* @param conversationId
* 根据会话id查询所有关联的会话扩展
* 删除会话扩展用
* @param conversationId 会话id
* @return
* @throws Exception
*/
public Long count(String conversationId) throws Exception {
EntityManager em = this.entityManagerContainer().get(IMMsg.class);
public List<String> listAllConversationExtIdsWithConversationId(String conversationId) throws Exception {
EntityManager em = this.entityManagerContainer().get(IMConversationExt.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<IMMsg> root = cq.from(IMMsg.class);
Predicate p = cb.equal(root.get(IMMsg_.conversationId), conversationId);
return em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<IMConversationExt> root = cq.from(IMConversationExt.class);
Predicate p = cb.equal(root.get(IMConversationExt_.conversationId), conversationId);
return em.createQuery(cq.select(root.get(IMConversationExt_.id)).where(p)).getResultList();
}
}
\ No newline at end of file
......@@ -26,16 +26,11 @@ public class ActionConversationCancelTop extends BaseAction {
ext = new IMConversationExt();
ext.setConversationId(conversationId);
ext.setPerson(effectivePerson.getDistinguishedName());
ext.setIsTop(false);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
} else {
ext.setIsTop(false);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
}
ext.setIsTop(false);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
WoId woId = new WoId();
woId.setId(ext.getId());
......
......@@ -30,16 +30,11 @@ public class ActionConversationRead extends BaseAction {
ext = new IMConversationExt();
ext.setConversationId(conversationId);
ext.setPerson(effectivePerson.getDistinguishedName());
ext.setLastReadTime(new Date());
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
} else {
ext.setLastReadTime(new Date());
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
}
ext.setLastReadTime(new Date());
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
WoId woId = new WoId();
woId.setId(ext.getId());
......
......@@ -28,16 +28,11 @@ public class ActionConversationSetTop extends BaseAction {
ext = new IMConversationExt();
ext.setConversationId(conversationId);
ext.setPerson(effectivePerson.getDistinguishedName());
ext.setIsTop(true);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
} else {
ext.setIsTop(true);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
}
ext.setIsTop(true);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
WoId woId = new WoId();
woId.setId(ext.getId());
......
......@@ -44,7 +44,6 @@ public class ActionDeleteConversationMsgs extends BaseAction {
if (msgIds == null || msgIds.isEmpty()) {
LOGGER.info("没有聊天记录,无需清空! conversationId:" + conversationId);
} else {
// 这里是1条条删除的 优化一下?
emc.beginTransaction(IMMsg.class);
emc.delete(IMMsg.class, msgIds);
emc.commit();
......
package com.x.message.assemble.communicate.jaxrs.im;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.WrapOutBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.message.assemble.communicate.Business;
import com.x.message.core.entity.IMConversation;
import com.x.message.core.entity.IMConversationExt;
import com.x.message.core.entity.IMMsg;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
/**
* Created by fancyLou on 2022/12/1.
* Copyright © 2022 O2. All rights reserved.
*/
public class ActionDeleteGroupConversation extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionDeleteGroupConversation.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String conversationId) throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("删除群聊 person:{}, conversationId:{}.", effectivePerson.getDistinguishedName(), conversationId);
}
ActionResult<Wo> result = new ActionResult<>();
if (StringUtils.isEmpty(conversationId)) {
throw new ExceptionEmptyId();
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
IMConversation conversation = emc.find(conversationId, IMConversation.class);
if (conversation == null) {
throw new ExceptionConversationNotExist();
}
// 判断权限 群聊只有管理员能删除 单聊不能删除
if (conversation.getType().equals(IMConversation.CONVERSATION_TYPE_SINGLE) || (conversation.getType().equals(IMConversation.CONVERSATION_TYPE_GROUP)
&& !effectivePerson.getDistinguishedName().equals(conversation.getAdminPerson()))) {
throw new ExceptionConvDeleteNoPermission();
}
// 先删除聊天记录
Business business = new Business(emc);
List<String> msgIds = business.imConversationFactory().listAllMsgIdsWithConversationId(conversationId);
if (msgIds == null || msgIds.isEmpty()) {
LOGGER.info("没有聊天记录,无需清空! conversationId:" + conversationId);
} else {
emc.beginTransaction(IMMsg.class);
emc.delete(IMMsg.class, msgIds);
emc.commit();
LOGGER.info("成功清空聊天记录!conversationId:" + conversationId + " msg size:" + msgIds.size() + " person:"
+ effectivePerson.getDistinguishedName());
}
// 然后删除会话扩展对象
List<String> extIds = business.imConversationFactory().listAllConversationExtIdsWithConversationId(conversationId);
if (extIds == null || extIds.isEmpty()) {
LOGGER.info("没有会话扩展,无需清空! conversationId:" + conversationId);
} else {
emc.beginTransaction(IMConversationExt.class);
emc.delete(IMConversationExt.class, extIds);
emc.commit();
LOGGER.info("成功删除会话扩展!conversationId:" + conversationId + " ext size:" + extIds.size() + " person:"
+ effectivePerson.getDistinguishedName());
}
// 最后删除会话对象
emc.beginTransaction(IMConversation.class);
emc.delete(IMConversation.class, conversation.getId());
emc.commit();
LOGGER.info("删除群聊成功==============================================");
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
}
return result;
}
public static class Wo extends WrapOutBoolean {
private static final long serialVersionUID = -2723486586341189508L;
}
}
package com.x.message.assemble.communicate.jaxrs.im;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.WrapOutBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.message.assemble.communicate.Business;
import com.x.message.core.entity.IMConversation;
import com.x.message.core.entity.IMConversationExt;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
/**
* 单聊 虚拟删除
* 在 IMConversationExt 会话扩展中添加一个删除标识,一个最新删除日期
* Created by fancyLou on 2022/12/1.
* Copyright © 2022 O2. All rights reserved.
*/
public class ActionDeleteSingleConversationVirtual extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionDeleteSingleConversationVirtual.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String conversationId) throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("单聊 个人虚拟删除会话 person:{}, conversationId:{}.", effectivePerson.getDistinguishedName(), conversationId);
}
ActionResult<Wo> result = new ActionResult<>();
if (StringUtils.isEmpty(conversationId)) {
throw new ExceptionEmptyId();
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
IMConversation conversation = emc.find(conversationId, IMConversation.class);
if (conversation == null) {
throw new ExceptionConversationNotExist();
}
// 这个Action操作是针对单聊的,不是单聊不给操作!
if (!conversation.getType().equals(IMConversation.CONVERSATION_TYPE_SINGLE)) {
throw new ExceptionConvDeleteNoPermission();
}
Business business = new Business(emc);
IMConversationExt ext = business.imConversationFactory()
.getConversationExt(effectivePerson.getDistinguishedName(), conversationId);
if (ext == null) {
ext = new IMConversationExt();
ext.setConversationId(conversationId);
ext.setPerson(effectivePerson.getDistinguishedName());
}
ext.setIsDeleted(true);
ext.setLastDeleteTime(new Date());
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
LOGGER.info("虚拟删除单聊成功 person {} ==============================================", effectivePerson.getDistinguishedName());
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
}
return result;
}
public static class Wo extends WrapOutBoolean {
private static final long serialVersionUID = -7547394049405029386L;
}
}
......@@ -2,7 +2,11 @@ package com.x.message.assemble.communicate.jaxrs.im;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.x.message.assemble.communicate.Business;
import com.x.message.core.entity.IMConversationExt;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.text.StringEscapeUtils;
......@@ -24,6 +28,8 @@ import com.x.message.core.entity.IMConversation;
import com.x.message.core.entity.IMMsg;
import com.x.message.core.entity.Message;
import static com.x.message.core.entity.IMConversation.CONVERSATION_TYPE_SINGLE;
public class ActionMsgCreate extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionMsgCreate.class);
......@@ -42,18 +48,37 @@ public class ActionMsgCreate extends BaseAction {
throw new ExceptionMsgEmptyBody();
}
msg.setCreatePerson(effectivePerson.getDistinguishedName());
escapeHTML(msg);
escapeHTML(msg); // 清除可执行的代码
LOGGER.info("escape html json:" + msg.getBody());
emc.beginTransaction(IMMsg.class);
emc.persist(msg, CheckPersistType.all);
emc.commit();
// 更新会话最后消息时间
emc.beginTransaction(IMConversation.class);
IMConversation conversation = emc.find(msg.getConversationId(), IMConversation.class);
conversation.setLastMessageTime(new Date());
emc.check(conversation, CheckPersistType.all);
emc.commit();
if (conversation.getType().equals(CONVERSATION_TYPE_SINGLE)) { // 单聊才有这种情况
List<String> persons = conversation.getPersonList().stream().filter((s)-> !Objects.equals(s, effectivePerson.getDistinguishedName())).collect(Collectors.toList());
if (!persons.isEmpty()) {
String person = persons.get(0);
// 更新会话扩展 如果已经删除的 有新消息就改为未删除
Business business = new Business(emc);
IMConversationExt ext = business.imConversationFactory()
.getConversationExt(person, msg.getConversationId());
if (ext != null) {
ext.setIsDeleted(false);
emc.beginTransaction(IMConversationExt.class);
emc.persist(ext, CheckPersistType.all);
emc.commit();
}
}
}
// 发送ws消息
sendWsMessage(conversation, msg, MessageConnector.TYPE_IM_CREATE, effectivePerson);
......
package com.x.message.assemble.communicate.jaxrs.im;
import java.util.Date;
import java.util.List;
import com.google.gson.JsonElement;
......@@ -15,6 +16,7 @@ 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.message.assemble.communicate.Business;
import com.x.message.core.entity.IMConversationExt;
import com.x.message.core.entity.IMMsg;
public class ActionMsgListWithConversationByPage extends BaseAction {
......@@ -36,18 +38,23 @@ public class ActionMsgListWithConversationByPage extends BaseAction {
if (wi.getConversationId() == null || wi.getConversationId().isEmpty()) {
throw new ExceptionMsgEmptyConversationId();
}
IMConversationExt ext = business.imConversationFactory().getConversationExt(effectivePerson.getDistinguishedName(), wi.getConversationId());
Date lastDeleteTime = null;
if (ext != null) {
lastDeleteTime = ext.getLastDeleteTime();
}
Integer adjustPage = this.adjustPage(page);
Integer adjustPageSize = this.adjustSize(size);
List<IMMsg> msgList = business.imConversationFactory().listMsgWithConversationByPage(adjustPage,
adjustPageSize, wi.getConversationId());
adjustPageSize, wi.getConversationId(), lastDeleteTime);
List<Wo> wos = Wo.copier.copy(msgList);
result.setData(wos);
result.setCount(business.imConversationFactory().count(wi.getConversationId()));
result.setCount(business.imConversationFactory().count(wi.getConversationId(), lastDeleteTime));
return result;
}
}
public class Wi extends GsonPropertyObject {
public static class Wi extends GsonPropertyObject {
private static final long serialVersionUID = 33404493425589133L;
......
......@@ -21,6 +21,7 @@ import com.x.message.core.entity.IMConversationExt;
import com.x.message.core.entity.IMMsg;
import static com.x.message.core.entity.IMConversation.CONVERSATION_TYPE_GROUP;
import static com.x.message.core.entity.IMConversation.CONVERSATION_TYPE_SINGLE;
public class ActionMyConversationList extends BaseAction {
......@@ -41,6 +42,7 @@ public class ActionMyConversationList extends BaseAction {
if (ext != null) {
wo.setIsTop(ext.getIsTop());
wo.setUnreadNumber(business.imConversationFactory().unreadNumber(ext));
wo.setExt(ext);
} else {
IMConversationExt conversationExt = new IMConversationExt();
conversationExt.setConversationId(wo.getId());
......@@ -50,18 +52,22 @@ public class ActionMyConversationList extends BaseAction {
emc.commit();
wo.setIsTop(false);
wo.setUnreadNumber(business.imConversationFactory().unreadNumber(conversationExt));
wo.setExt(conversationExt);
}
}
// 删除空的会话
List<Wo> trueWos = wos.stream().filter((wo)-> {
List<Wo> trueWos = wos.stream().filter((wo) -> { // 已删除的单聊不展现
if (wo.getExt() != null && wo.getExt().getIsDeleted() != null && wo.getExt().getIsDeleted() && wo.getType().equals(CONVERSATION_TYPE_SINGLE)) {
return false;
}
return true;
}).filter((wo)-> {// 删除空的会话
WoMsg woMsg;
try {
woMsg = WoMsg.copier.copy(business.imConversationFactory().lastMessage(wo.getId()));
if (woMsg != null) {
wo.setLastMessage(woMsg);
}
woMsg = WoMsg.copier.copy(business.imConversationFactory().lastMessage(wo.getId()));
if (woMsg != null) {
wo.setLastMessage(woMsg);
}
} catch (Exception e) {
woMsg = null;
}
......@@ -83,6 +89,35 @@ public class ActionMyConversationList extends BaseAction {
return 0;
}
}).collect(Collectors.toList());
// List<Wo> trueWos = wos.stream().filter((wo)-> {
// WoMsg woMsg;
// try {
// woMsg = WoMsg.copier.copy(business.imConversationFactory().lastMessage(wo.getId()));
// if (woMsg != null) {
// wo.setLastMessage(woMsg);
// }
// } catch (Exception e) {
// woMsg = null;
// }
// // 群聊不管有没有聊天消息都展现。
// if (wo.getType() != null && wo.getType().equals(CONVERSATION_TYPE_GROUP)) {
// return true;
// }
// // 单聊没有聊天消息就不展现
// return (woMsg != null);
// }).sorted((a, b)-> {
// if (a.lastMessage == null || b.lastMessage == null) {
// return 0;
// }
// Date aC = a.lastMessage.getCreateTime();
// Date bC = b.lastMessage.getCreateTime();
// if (aC != null && bC != null ) {
// return aC.getTime() > bC.getTime() ? -1 : 1;
// } else {
// return 0;
// }
// }).collect(Collectors.toList());
result.setData(trueWos);
return result;
}
......@@ -98,6 +133,8 @@ public class ActionMyConversationList extends BaseAction {
@FieldDescribe("最后一条消息.")
private WoMsg lastMessage;
// 扩展 业务操作使用
private IMConversationExt ext;
private static final long serialVersionUID = 3434938936805201380L;
static WrapCopier<IMConversation, Wo> copier = WrapCopierFactory.wo(IMConversation.class, Wo.class, null,
......@@ -126,6 +163,14 @@ public class ActionMyConversationList extends BaseAction {
public void setLastMessage(WoMsg lastMessage) {
this.lastMessage = lastMessage;
}
public IMConversationExt getExt() {
return ext;
}
public void setExt(IMConversationExt ext) {
this.ext = ext;
}
}
public static class WoMsg extends IMMsg {
......
package com.x.message.assemble.communicate.jaxrs.im;
import com.x.base.core.project.exception.PromptException;
class ExceptionConvDeleteNoPermission extends PromptException {
private static final long serialVersionUID = 6058719120644397872L;
ExceptionConvDeleteNoPermission() {
super("没有权限删除会话!");
}
}
......@@ -243,6 +243,42 @@ public class ImAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除群聊,只有群主可以删除.", action = ActionDeleteGroupConversation.class)
@DELETE
@Path("conversation/{id}/group")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void deleteGroupConversation(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("会话ID") @PathParam("id") String id) {
ActionResult<ActionDeleteGroupConversation.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDeleteGroupConversation().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除单聊会话.", action = ActionDeleteSingleConversationVirtual.class)
@DELETE
@Path("conversation/{id}/single")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void deleteSingleConversation(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("会话ID") @PathParam("id") String id) {
ActionResult<ActionDeleteSingleConversationVirtual.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDeleteSingleConversationVirtual().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/************* im message ************/
@JaxrsMethodDescribe(value = "创建消息,发送消息到某一个会话中.", action = ActionMsgCreate.class)
......
......@@ -83,6 +83,18 @@ public class IMConversationExt extends SliceJpaObject {
private Date lastReadTime;
public static final String lastDeleteTime_FIELDNAME = "lastDeleteTime";
@FieldDescribe("当前用户把会话删除的时间")
@Column(name = ColumnNamePrefix + lastDeleteTime_FIELDNAME)
private Date lastDeleteTime;
public static final String isDeleted_FIELDNAME = "isDeleted";
@FieldDescribe("是否删除,个人删除后不显示到会话列表,如果会话中有新的聊天消息会重置为true.")
@Column(name = ColumnNamePrefix + isDeleted_FIELDNAME)
private Boolean isDeleted = false;
public String getConversationId() {
return conversationId;
}
......@@ -114,4 +126,20 @@ public class IMConversationExt extends SliceJpaObject {
public void setLastReadTime(Date lastReadTime) {
this.lastReadTime = lastReadTime;
}
public Date getLastDeleteTime() {
return lastDeleteTime;
}
public void setLastDeleteTime(Date lastDeleteTime) {
this.lastDeleteTime = lastDeleteTime;
}
public Boolean getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(Boolean deleted) {
isDeleted = deleted;
}
}
......@@ -8,8 +8,8 @@
<div class="o2_im_chat_content_title_menu_item" data-o2-element="chatTitleMoreMenuItem1Node" data-o2-events="click:tapUpdateConvTitle">{{$.lp.modifyGroupName}}</div>
<div class="o2_im_chat_content_title_menu_item" data-o2-element="chatTitleMoreMenuItem2Node" data-o2-events="click:tapUpdateConvMembers">
{{$.lp.modifyMember}}</div>
<div class="o2_im_chat_content_title_menu_item" data-o2-element="chatTitleMoreMenuItem3Node" data-o2-events="click:tapClearMsg" style="display: none;">
{{$.lp.clearAllMsg}}</div>
<div class="o2_im_chat_content_title_menu_item" data-o2-element="chatTitleMoreMenuItem3Node" data-o2-events="click:tapDeleteConversation" style="display: none;">
{{$.lp.deleteConversation}}</div>
</div>
<!-- 业务对象的应用icon 流程默认图标"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png" -->
</div>
......
......@@ -78,7 +78,7 @@ MWF.xApplication.IMV2.Main = new Class({
//设置content
this.app.content = this.o2ImMainNode;
// 给websocket 添加撤回消息回调函数
if (layout.desktop && layout.desktop.socket) {
if (layout.desktop && layout.desktop.socket && layout.desktop.socket.addImListener) {
layout.desktop.socket.addImListener("im_revoke", this.revokeMsgCallback.bind(this));
layout.desktop.socket.addImListener("im_create", this.createNewMsgCallback.bind(this));
}
......@@ -810,22 +810,56 @@ MWF.xApplication.IMV2.ChatNodeBox = new Class({
var form = new MWF.xApplication.IMV2.CreateConversationForm(this.main, {}, { "title": this.lp.modifyMember, "personCount": 0, "personSelected": members, "isUpdateMember": true }, { app: this.main.app });
form.create()
},
// 点击菜单 清空聊天记录
tapClearMsg: function(e) {
// 点击菜单 删除会话
tapDeleteConversation: function(e) {
var _self = this;
MWF.xDesktop.confirm("info", this.chatTitleNode, this.lp.alert, this.lp.messageClearAllMsgAlert, 400, 150, function() {
o2.Actions.load("x_message_assemble_communicate").ImAction.clearConversationMsg(_self.conversationId, function (json) {
_self._reclickConv();
}, function (error) {
console.log(error);
_self.app.notice(error, "error", _self.app.content);
});
this.close();
}, function(){
this.close();
}, null, null, "o2");
var con = null;
for (var i = 0; i < this.main.conversationNodeItemList.length; i++) {
var c = this.main.conversationNodeItemList[i];
if (this.conversationId == c.data.id) {
con = c.data;
break;
}
}
if (con) {
var msg = this.lp.messageDeleteSingleConversationAlert;
if (con.type === "single") {
msg = this.lp.messageDeleteSingleConversationAlert;
} else {
msg = this.lp.messageDeleteGroupConversationAlert;
}
MWF.xDesktop.confirm("info", this.chatTitleNode, this.lp.alert, msg, 400, 150, function() {
if (con.type === "single") {
_self.deleteSingleConversation();
} else {
_self.deleteGroupConversation();
}
this.close();
}, function(){
this.close();
}, null, null, "o2");
} else {
console.error('没有找到会话对象。。。。。');
}
},
// 删除群聊
deleteGroupConversation: function() {
o2.Actions.load("x_message_assemble_communicate").ImAction.deleteGroupConversation(this.conversationId, function (json) {
this.main.refresh();
}.bind(this), function (error) {
console.error(error);
this.app.notice(error, "error", this.app.content);
}.bind(this));
},
deleteSingleConversation: function() {
o2.Actions.load("x_message_assemble_communicate").ImAction.deleteSingleConversation(this.conversationId, function (json) {
this.main.refresh();
}.bind(this), function (error) {
console.error(error);
this.app.notice(error, "error", this.app.content);
}.bind(this));
},
//点击表情按钮
showEmojiBox: function () {
if (!this.emojiBoxNode) {
......
......@@ -41,7 +41,7 @@ MWF.xApplication.IMV2.LP = {
"modifyGroupName": "Modify Name",
"groupName": "Name",
"clearAllMsg": "Clear chat history",
"deleteConversation": "Delete Conversation",
"msgMenuItemRevokeMemberMsg": "Revoke member message",
"msgMenuItemRevokeMsg": "Revoke",
......@@ -62,5 +62,6 @@ MWF.xApplication.IMV2.LP = {
"sendKeyTips": "Ctrl + Enter Line feed",
"file": "[File]",
"messageXadminNotSupport": "The xadmin cannot use chat, please switch to normal user login!",
"messageClearAllMsgAlert": "Are you sure you want to clear the chat records? After clearing, everyone in the current session will not see these chat records?"
"messageDeleteSingleConversationAlert": "确定要删除当前会话吗,删除后将看不到以前的聊天记录?",
"messageDeleteGroupConversationAlert": "确定要删除当前会话吗,这会解散当前群聊并删除聊天记录?"
};
......@@ -41,7 +41,7 @@ MWF.xApplication.IMV2.LP = {
"modifyGroupName": "修改群名",
"groupName": "群名",
"clearAllMsg": "清空聊天记录",
"deleteConversation": "删除会话",
"msgMenuItemRevokeMemberMsg": "撤回成员消息",
"msgMenuItemRevokeMsg": "撤回",
......@@ -54,7 +54,7 @@ MWF.xApplication.IMV2.LP = {
"msgShareError": "分享、转发消息失败!",
"settingsClearMsg": "是否开启聊天消息清除功能:",
"settingsClearMsg": "是否开启会话删除功能:",
"settingsRevokeMsg": "是否开启聊天消息撤回功能:",
"enterMessage": "输入消息内容",
......@@ -62,5 +62,6 @@ MWF.xApplication.IMV2.LP = {
"sendKeyTips": "Ctrl + Enter 换行",
"file": "[文件]",
"messageXadminNotSupport": "xadmin用户无法使用聊聊,请切换正常的用户登录!",
"messageClearAllMsgAlert": "确定要清空聊天记录吗,清空后当前会话所有人都将看不到这些聊天记录?"
"messageDeleteSingleConversationAlert": "确定要删除当前会话吗,删除后将看不到以前的聊天记录?",
"messageDeleteGroupConversationAlert": "确定要删除当前会话吗,这会解散当前群聊并删除聊天记录?"
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册