@@ -150,56 +150,6 @@ func (c *Conversation) SetConversationListener(listener func() open_im_sdk_callb
150
150
c .ConversationListener = listener
151
151
}
152
152
153
- func (c * Conversation ) msgStructToLocalChatLog (src * sdk_struct.MsgStruct ) * model_struct.LocalChatLog {
154
- var lc model_struct.LocalChatLog
155
- copier .Copy (& lc , src )
156
- switch src .ContentType {
157
- case constant .Text :
158
- lc .Content = utils .StructToJsonString (src .TextElem )
159
- case constant .Picture :
160
- lc .Content = utils .StructToJsonString (src .PictureElem )
161
- case constant .Sound :
162
- lc .Content = utils .StructToJsonString (src .SoundElem )
163
- case constant .Video :
164
- lc .Content = utils .StructToJsonString (src .VideoElem )
165
- case constant .File :
166
- lc .Content = utils .StructToJsonString (src .FileElem )
167
- case constant .AtText :
168
- lc .Content = utils .StructToJsonString (src .AtTextElem )
169
- case constant .Merger :
170
- lc .Content = utils .StructToJsonString (src .MergeElem )
171
- case constant .Card :
172
- lc .Content = utils .StructToJsonString (src .CardElem )
173
- case constant .Location :
174
- lc .Content = utils .StructToJsonString (src .LocationElem )
175
- case constant .Custom :
176
- lc .Content = utils .StructToJsonString (src .CustomElem )
177
- case constant .Quote :
178
- lc .Content = utils .StructToJsonString (src .QuoteElem )
179
- case constant .Face :
180
- lc .Content = utils .StructToJsonString (src .FaceElem )
181
- case constant .AdvancedText :
182
- lc .Content = utils .StructToJsonString (src .AdvancedTextElem )
183
- default :
184
- lc .Content = utils .StructToJsonString (src .NotificationElem )
185
- }
186
- if src .SessionType == constant .WriteGroupChatType || src .SessionType == constant .ReadGroupChatType {
187
- lc .RecvID = src .GroupID
188
- }
189
- lc .AttachedInfo = utils .StructToJsonString (src .AttachedInfoElem )
190
- return & lc
191
- }
192
- func (c * Conversation ) msgDataToLocalChatLog (src * sdkws.MsgData ) * model_struct.LocalChatLog {
193
- var lc model_struct.LocalChatLog
194
- copier .Copy (& lc , src )
195
- lc .Content = string (src .Content )
196
- if src .SessionType == constant .WriteGroupChatType || src .SessionType == constant .ReadGroupChatType {
197
- lc .RecvID = src .GroupID
198
-
199
- }
200
- return & lc
201
-
202
- }
203
153
func (c * Conversation ) msgDataToLocalErrChatLog (src * model_struct.LocalChatLog ) * model_struct.LocalErrChatLog {
204
154
var lc model_struct.LocalErrChatLog
205
155
copier .Copy (& lc , src )
@@ -345,7 +295,7 @@ func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct,
345
295
if ! isOnlineOnly {
346
296
oldMessage , err := c .db .GetMessage (ctx , lc .ConversationID , s .ClientMsgID )
347
297
if err != nil {
348
- localMessage := c . msgStructToLocalChatLog (s )
298
+ localMessage := MsgStructToLocalChatLog (s )
349
299
err := c .db .InsertMessage (ctx , lc .ConversationID , localMessage )
350
300
if err != nil {
351
301
return nil , err
@@ -566,7 +516,7 @@ func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct,
566
516
}
567
517
if utils .IsContainInt (int (s .ContentType ), []int {constant .Picture , constant .Sound , constant .Video , constant .File }) {
568
518
if ! isOnlineOnly {
569
- localMessage := c . msgStructToLocalChatLog (s )
519
+ localMessage := MsgStructToLocalChatLog (s )
570
520
log .ZDebug (ctx , "update message is " , "localMessage" , localMessage )
571
521
err = c .db .UpdateMessage (ctx , lc .ConversationID , localMessage )
572
522
if err != nil {
@@ -589,7 +539,7 @@ func (c *Conversation) SendMessageNotOss(ctx context.Context, s *sdk_struct.MsgS
589
539
if ! isOnlineOnly {
590
540
oldMessage , err := c .db .GetMessage (ctx , lc .ConversationID , s .ClientMsgID )
591
541
if err != nil {
592
- localMessage := c . msgStructToLocalChatLog (s )
542
+ localMessage := MsgStructToLocalChatLog (s )
593
543
err := c .db .InsertMessage (ctx , lc .ConversationID , localMessage )
594
544
if err != nil {
595
545
return nil , err
@@ -650,7 +600,7 @@ func (c *Conversation) SendMessageNotOss(ctx context.Context, s *sdk_struct.MsgS
650
600
}
651
601
if utils .IsContainInt (int (s .ContentType ), []int {constant .Picture , constant .Sound , constant .Video , constant .File }) {
652
602
if isOnlineOnly {
653
- localMessage := c . msgStructToLocalChatLog (s )
603
+ localMessage := MsgStructToLocalChatLog (s )
654
604
err = c .db .UpdateMessage (ctx , lc .ConversationID , localMessage )
655
605
if err != nil {
656
606
return nil , err
@@ -750,39 +700,8 @@ func (c *Conversation) FindMessageList(ctx context.Context, req []*sdk_params_ca
750
700
if err == nil {
751
701
var tempMessageList []* sdk_struct.MsgStruct
752
702
for _ , message := range messages {
753
- temp := sdk_struct.MsgStruct {}
754
- temp .ClientMsgID = message .ClientMsgID
755
- temp .ServerMsgID = message .ServerMsgID
756
- temp .CreateTime = message .CreateTime
757
- temp .SendTime = message .SendTime
758
- temp .SessionType = message .SessionType
759
- temp .SendID = message .SendID
760
- temp .RecvID = message .RecvID
761
- temp .MsgFrom = message .MsgFrom
762
- temp .ContentType = message .ContentType
763
- temp .SenderPlatformID = message .SenderPlatformID
764
- temp .SenderNickname = message .SenderNickname
765
- temp .SenderFaceURL = message .SenderFaceURL
766
- temp .Content = message .Content
767
- temp .Seq = message .Seq
768
- temp .IsRead = message .IsRead
769
- temp .Status = message .Status
770
- temp .AttachedInfo = message .AttachedInfo
771
- temp .Ex = message .Ex
772
- temp .LocalEx = message .LocalEx
773
- err := c .msgHandleByContentType (& temp )
774
- if err != nil {
775
- log .ZError (ctx , "msgHandleByContentType err" , err , "message" , temp )
776
- continue
777
- }
778
- switch message .SessionType {
779
- case constant .WriteGroupChatType :
780
- fallthrough
781
- case constant .ReadGroupChatType :
782
- temp .GroupID = temp .RecvID
783
- temp .RecvID = c .loginUserID
784
- }
785
- tempMessageList = append (tempMessageList , & temp )
703
+ temp := LocalChatLogToMsgStruct (message )
704
+ tempMessageList = append (tempMessageList , temp )
786
705
}
787
706
findResultItem := sdk_params_callback.SearchByConversationResult {}
788
707
findResultItem .ConversationID = v .conversation .ConversationID
@@ -916,7 +835,7 @@ func (c *Conversation) InsertSingleMessageToLocalStorage(ctx context.Context, s
916
835
s .SendTime = utils .GetCurrentTimestampByMill ()
917
836
s .SessionType = constant .SingleChatType
918
837
s .Status = constant .MsgStatusSendSuccess
919
- localMessage := c . msgStructToLocalChatLog (s )
838
+ localMessage := MsgStructToLocalChatLog (s )
920
839
conversation .LatestMsg = utils .StructToJsonString (s )
921
840
conversation .ConversationType = constant .SingleChatType
922
841
conversation .LatestMsgSendTime = s .SendTime
@@ -956,7 +875,7 @@ func (c *Conversation) InsertGroupMessageToLocalStorage(ctx context.Context, s *
956
875
s .SendTime = utils .GetCurrentTimestampByMill ()
957
876
s .SessionType = conversation .ConversationType
958
877
s .Status = constant .MsgStatusSendSuccess
959
- localMessage := c . msgStructToLocalChatLog (s )
878
+ localMessage := MsgStructToLocalChatLog (s )
960
879
conversation .LatestMsg = utils .StructToJsonString (s )
961
880
conversation .LatestMsgSendTime = s .SendTime
962
881
conversation .FaceURL = s .SenderFaceURL
@@ -1015,7 +934,6 @@ func (c *Conversation) initBasicInfo(ctx context.Context, message *sdk_struct.Ms
1015
934
message .MsgFrom = msgFrom
1016
935
message .ContentType = contentType
1017
936
message .SenderPlatformID = c .platformID
1018
- message .IsExternalExtensions = c .IsExternalExtensions
1019
937
return nil
1020
938
}
1021
939
0 commit comments