|
|
@@ -38,7 +38,7 @@ public class ConversationService {
|
|
|
(userId + "-" + snd.getPublishersId()) : (snd.getPublishersId() + "-" + userId);
|
|
|
|
|
|
|
|
|
- Conversation conversationFrom = conversationRepo
|
|
|
+ /* Conversation conversationFrom = conversationRepo
|
|
|
.findFirstByUserIdAndToUserIdOrderByIdDesc(userId, snd.getPublishersId());
|
|
|
if (conversationFrom == null) {
|
|
|
conversationFrom = Conversation.builder()
|
|
|
@@ -52,9 +52,29 @@ public class ConversationService {
|
|
|
}
|
|
|
conversationFrom.setOrgId(snd.getOrgId());
|
|
|
conversationFrom.setContact(contact);
|
|
|
+ conversationRepo.save(conversationFrom);*/
|
|
|
+
|
|
|
+ Conversation conversationFrom = conversationRepo.findBySndId(sndId);
|
|
|
+
|
|
|
+ if (conversationFrom == null) {
|
|
|
+ conversationFrom = Conversation.builder()
|
|
|
+ .sessionId(sessionId)
|
|
|
+ .userId(userId)
|
|
|
+ .toUserId(snd.getPublishersId())
|
|
|
+ .orgId(snd.getOrgId())
|
|
|
+ .contact(contact)
|
|
|
+ .type(ConversationType.DOCKING)
|
|
|
+ .sndId(sndId)
|
|
|
+ .resSndType(snd.getType())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ conversationFrom.setOrgId(snd.getOrgId());
|
|
|
+ conversationFrom.setContact(contact);
|
|
|
conversationRepo.save(conversationFrom);
|
|
|
|
|
|
- Conversation conversationTo = conversationRepo
|
|
|
+ //-------------------------------
|
|
|
+
|
|
|
+ /* Conversation conversationTo = conversationRepo
|
|
|
.findFirstByUserIdAndToUserIdOrderByIdDesc(snd.getPublishersId(), userId);
|
|
|
if (conversationTo == null) {
|
|
|
conversationTo = Conversation.builder()
|
|
|
@@ -68,7 +88,20 @@ public class ConversationService {
|
|
|
}
|
|
|
conversationTo.setContact(contact);
|
|
|
conversationTo.setOrgId(snd.getOrgId());
|
|
|
- conversationRepo.save(conversationTo);
|
|
|
+ conversationRepo.save(conversationTo);*/
|
|
|
+
|
|
|
+
|
|
|
+//
|
|
|
+// Conversation conversationTo = Conversation.builder()
|
|
|
+// .sessionId(sessionId)
|
|
|
+// .userId(snd.getPublishersId())
|
|
|
+// .toUserId(userId)
|
|
|
+// .orgId(snd.getOrgId())
|
|
|
+// .contact(contact)
|
|
|
+// .type(ConversationType.PUBLISH)
|
|
|
+// .build();
|
|
|
+// conversationRepo.save(conversationTo);
|
|
|
+ //------------------------------------
|
|
|
|
|
|
messageService.send(userId, snd.getPublishersId(), sessionId, MessageType.TEXT, content);
|
|
|
messageService.send(userId, snd.getPublishersId(), sessionId, MessageType.SND, JSON.toJSONString(snd));
|
|
|
@@ -89,22 +122,22 @@ public class ConversationService {
|
|
|
dockingRecordFrom.setContact(contact);
|
|
|
dockingRecordRepo.save(dockingRecordFrom);
|
|
|
|
|
|
- DockingRecord dockingRecordTo = dockingRecordRepo
|
|
|
- .findFirstByUserIdAndSndIdAndRoleAndStatusInOrderByIdDesc(snd
|
|
|
- .getPublishersId(), sndId, DockingRole.PUBLISH,
|
|
|
- Arrays.asList(DockingStatus.PENDING, DockingStatus.IN_PROGRESS));
|
|
|
- if (dockingRecordTo == null) {
|
|
|
- dockingRecordTo = DockingRecord.builder()
|
|
|
- .userId(snd.getPublishersId())
|
|
|
- .orgId(snd.getOrgId())
|
|
|
- .sndId(sndId)
|
|
|
- .role(DockingRole.PUBLISH)
|
|
|
- .status(DockingStatus.PENDING)
|
|
|
- .build();
|
|
|
- }
|
|
|
- dockingRecordTo.setConversationId(conversationTo.getId());
|
|
|
- dockingRecordTo.setContact(contact);
|
|
|
- dockingRecordRepo.save(dockingRecordTo);
|
|
|
+// DockingRecord dockingRecordTo = dockingRecordRepo
|
|
|
+// .findFirstByUserIdAndSndIdAndRoleAndStatusInOrderByIdDesc(snd
|
|
|
+// .getPublishersId(), sndId, DockingRole.PUBLISH,
|
|
|
+// Arrays.asList(DockingStatus.PENDING, DockingStatus.IN_PROGRESS));
|
|
|
+// if (dockingRecordTo == null) {
|
|
|
+// dockingRecordTo = DockingRecord.builder()
|
|
|
+// .userId(snd.getPublishersId())
|
|
|
+// .orgId(snd.getOrgId())
|
|
|
+// .sndId(sndId)
|
|
|
+// .role(DockingRole.PUBLISH)
|
|
|
+// .status(DockingStatus.PENDING)
|
|
|
+// .build();
|
|
|
+// }
|
|
|
+// dockingRecordTo.setConversationId(conversationTo.getId());
|
|
|
+// dockingRecordTo.setContact(contact);
|
|
|
+// dockingRecordRepo.save(dockingRecordTo);
|
|
|
}
|
|
|
|
|
|
public ConversationDTO get(Long id) {
|