Skip to content

Commit

Permalink
refactor: improve createMessage and sendMessage interface. (#734)
Browse files Browse the repository at this point in the history
* add .gitignore content.

* refactor: improve createMessage and sendMessage interface.

* fix interface args.

* fix nil pointer error.

* fix test error.
  • Loading branch information
mo3et authored Nov 14, 2024
1 parent 9f5abc4 commit a5324fa
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 394 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ components
logs
out-test
*.db
open-im-sdk-core.*

### Backup ###
*.bak
Expand Down
10 changes: 9 additions & 1 deletion internal/conversation_msg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ func (c *Conversation) GetConversationIDBySessionType(_ context.Context, sourceI
}

func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct, recvID, groupID string, p *sdkws.OfflinePushInfo, isOnlineOnly bool) (*sdk_struct.MsgStruct, error) {
// Message is created by URL
if (s.FileElem != nil && s.FileElem.SourceURL != "") ||
(s.SoundElem != nil && s.SoundElem.SourceURL != "") ||
(s.VideoElem != nil && s.VideoElem.VideoURL != "") ||
(s.PictureElem != nil && (s.PictureElem.SourcePicture.Url != "" || s.PictureElem.BigPicture.Url != "" || s.PictureElem.SnapshotPicture.Url != "")) {
return c.sendMessageNotOss(ctx, s, recvID, groupID, p, isOnlineOnly)
}

filepathExt := func(name ...string) string {
for _, path := range name {
if ext := filepath.Ext(path); ext != "" {
Expand Down Expand Up @@ -531,7 +539,7 @@ func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct,
return c.sendMessageToServer(ctx, s, lc, callback, delFile, p, options, isOnlineOnly)
}

func (c *Conversation) SendMessageNotOss(ctx context.Context, s *sdk_struct.MsgStruct, recvID, groupID string,
func (c *Conversation) sendMessageNotOss(ctx context.Context, s *sdk_struct.MsgStruct, recvID, groupID string,
p *sdkws.OfflinePushInfo, isOnlineOnly bool) (*sdk_struct.MsgStruct, error) {
options := make(map[string]bool, 2)
lc, err := c.checkID(ctx, s, recvID, groupID, options)
Expand Down
Loading

0 comments on commit a5324fa

Please sign in to comment.