Commit 53fc9ae4fc0778b9717802854983c62f322386ae
1 parent
ae36d1ad
✨ feat(im): 优化【消息引用】的功能,来自第一波 code review
Showing
2 changed files
with
7 additions
and
2 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/websocket/dto/message/QuoteMessage.java
| @@ -22,6 +22,11 @@ public class QuoteMessage { | @@ -22,6 +22,11 @@ public class QuoteMessage { | ||
| 22 | public static final String FIELD_NAME = "quote"; | 22 | public static final String FIELD_NAME = "quote"; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | + * QuoteMessage 里 messageId 字段名 | ||
| 26 | + */ | ||
| 27 | + public static final String FIELD_MESSAGE_ID = "messageId"; | ||
| 28 | + | ||
| 29 | + /** | ||
| 25 | * 被引用消息编号 | 30 | * 被引用消息编号 |
| 26 | */ | 31 | */ |
| 27 | private Long messageId; | 32 | private Long messageId; |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/util/ImMessageUtils.java
| @@ -28,7 +28,7 @@ public class ImMessageUtils { | @@ -28,7 +28,7 @@ public class ImMessageUtils { | ||
| 28 | if (!(quoteRaw instanceof Map)) { | 28 | if (!(quoteRaw instanceof Map)) { |
| 29 | return null; | 29 | return null; |
| 30 | } | 30 | } |
| 31 | - return Convert.toLong(((Map<?, ?>) quoteRaw).get("messageId")); | 31 | + return Convert.toLong(((Map<?, ?>) quoteRaw).get(QuoteMessage.FIELD_MESSAGE_ID)); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| @@ -58,7 +58,7 @@ public class ImMessageUtils { | @@ -58,7 +58,7 @@ public class ImMessageUtils { | ||
| 58 | return content; | 58 | return content; |
| 59 | } | 59 | } |
| 60 | Map<String, Object> map = JsonUtils.parseMap(content); | 60 | Map<String, Object> map = JsonUtils.parseMap(content); |
| 61 | - if (map == null || !map.containsKey(QuoteMessage.FIELD_NAME)) { | 61 | + if (map == null) { |
| 62 | return content; | 62 | return content; |
| 63 | } | 63 | } |
| 64 | map.remove(QuoteMessage.FIELD_NAME); | 64 | map.remove(QuoteMessage.FIELD_NAME); |