Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve createMessage and sendMessage interface. #734

Merged
merged 8 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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