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: remove batchListener. #729

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
146 changes: 73 additions & 73 deletions .github/workflows/update-version-file-on-release.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
name: Update Version File on Release
# name: Update Version File on Release

on:
release:
types: [created]
# on:
# release:
# types: [created]

jobs:
update-version:
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# jobs:
# update-version:
# runs-on: ubuntu-latest
# env:
# TAG_VERSION: ${{ github.event.release.tag_name }}
# steps:
# # Step 1: Checkout the original repository's code
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# Step 2: Set up Git with official account
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# # Step 2: Set up Git with official account
# - name: Set up Git
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"

# Step 3: Check and delete existing tag
- name: Check and delete existing tag
run: |
if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
git tag -d ${{ env.TAG_VERSION }}
git push --delete origin ${{ env.TAG_VERSION }}
fi
# # Step 3: Check and delete existing tag
# - name: Check and delete existing tag
# run: |
# if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
# git tag -d ${{ env.TAG_VERSION }}
# git push --delete origin ${{ env.TAG_VERSION }}
# fi

# Step 4: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version
# # Step 4: Update version file
# - name: Update version file
# run: |
# echo "${{ env.TAG_VERSION }}" > version/version

# Step 5: Commit and push changes
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${{ github.ref }}
# # Step 5: Commit and push changes
# - name: Commit and push changes
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git add version/version
# git commit -m "Update version to ${{ env.TAG_VERSION }}"
# git push origin HEAD:${{ github.ref }}

# Step 6: Create and push tag
- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ env.TAG_VERSION }}
git push origin ${{ env.TAG_VERSION }}
# # Step 6: Create and push tag
# - name: Create and push tag
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git tag ${{ env.TAG_VERSION }}
# git push origin ${{ env.TAG_VERSION }}

# Step 8: Find and Publish Draft Release
- name: Find and Publish Draft Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Get the list of releases
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
# # Step 8: Find and Publish Draft Release
# - name: Find and Publish Draft Release
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# // Get the list of releases
# const releases = await github.rest.repos.listReleases({
# owner: context.repo.owner,
# repo: context.repo.repo
# });

// Find the draft release where the title and tag_name are the same
const draftRelease = releases.data.find(release =>
release.draft && release.name === release.tag_name
);
# // Find the draft release where the title and tag_name are the same
# const draftRelease = releases.data.find(release =>
# release.draft && release.name === release.tag_name
# );

if (draftRelease) {
// Publish the draft release using the release_id
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draftRelease.id, // Use release_id
draft: false
});
# if (draftRelease) {
# // Publish the draft release using the release_id
# await github.rest.repos.updateRelease({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id: draftRelease.id, // Use release_id
# draft: false
# });

core.info(`Draft Release ${draftRelease.tag_name} published successfully.`);
} else {
core.info("No matching draft release found.");
}
# core.info(`Draft Release ${draftRelease.tag_name} published successfully.`);
# } else {
# core.info("No matching draft release found.");
# }
60 changes: 2 additions & 58 deletions internal/conversation_msg/conversation_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type Conversation struct {
ConversationListener func() open_im_sdk_callback.OnConversationListener
msgListener func() open_im_sdk_callback.OnAdvancedMsgListener
msgKvListener func() open_im_sdk_callback.OnMessageKvInfoListener
batchMsgListener func() open_im_sdk_callback.OnBatchMsgListener
businessListener func() open_im_sdk_callback.OnCustomBusinessListener
recvCH chan common.Cmd2Value
loginUserID string
Expand Down Expand Up @@ -84,10 +83,6 @@ func (c *Conversation) SetMsgKvListener(msgKvListener func() open_im_sdk_callbac
c.msgKvListener = msgKvListener
}

func (c *Conversation) SetBatchMsgListener(batchMsgListener func() open_im_sdk_callback.OnBatchMsgListener) {
c.batchMsgListener = batchMsgListener
}

func (c *Conversation) SetBusinessListener(businessListener func() open_im_sdk_callback.OnCustomBusinessListener) {
c.businessListener = businessListener
}
Expand Down Expand Up @@ -431,11 +426,8 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
}
log.ZDebug(ctx, "before trigger msg", "cost time", time.Since(b).Seconds(), "len", len(allMsg))

if c.batchMsgListener() != nil {
c.batchNewMessages(ctx, newMessages, conversationChangedSet, newConversationSet, onlineMap)
} else {
c.newMessage(ctx, newMessages, conversationChangedSet, newConversationSet, onlineMap)
}
c.newMessage(ctx, newMessages, conversationChangedSet, newConversationSet, onlineMap)

if len(newConversationSet) > 0 {
c.doUpdateConversation(common.Cmd2Value{Value: common.UpdateConNode{Action: constant.NewConDirect, Args: utils.StructToJsonString(mapConversationToList(newConversationSet))}})
}
Expand Down Expand Up @@ -738,54 +730,6 @@ func (c *Conversation) newMessage(ctx context.Context, newMessagesList sdk_struc
}
}

func (c *Conversation) batchNewMessages(ctx context.Context, newMessagesList sdk_struct.NewMsgList, conversationChanged, newConversation map[string]*model_struct.LocalConversation, onlineMsg map[onlineMsgKey]struct{}) {
if len(newMessagesList) == 0 {
log.ZWarn(ctx, "newMessagesList is empty", errs.New("newMessagesList is empty"))
return
}

sort.Sort(newMessagesList)
var needNotificationMsgList sdk_struct.NewMsgList

// offline
if c.GetBackground() {
u, err := c.user.GetSelfUserInfo(ctx)
if err != nil {
log.ZWarn(ctx, "GetSelfUserInfo err", err)
}

if u.GlobalRecvMsgOpt != constant.ReceiveMessage {
return
}

for _, w := range newMessagesList {
conversationID := utils.GetConversationIDByMsg(w)
if v, ok := conversationChanged[conversationID]; ok && v.RecvMsgOpt == constant.ReceiveMessage {
needNotificationMsgList = append(needNotificationMsgList, w)
}
if v, ok := newConversation[conversationID]; ok && v.RecvMsgOpt == constant.ReceiveMessage {
needNotificationMsgList = append(needNotificationMsgList, w)
}
}

if len(needNotificationMsgList) != 0 {
c.batchMsgListener().OnRecvOfflineNewMessages(utils.StructToJsonString(needNotificationMsgList))
}
} else { // online
for _, w := range newMessagesList {
if w.ContentType == constant.Typing {
continue
}

needNotificationMsgList = append(needNotificationMsgList, w)
}

if len(needNotificationMsgList) != 0 {
c.batchMsgListener().OnRecvNewMessages(utils.StructToJsonString(needNotificationMsgList))
}
}
}

func (c *Conversation) msgConvert(msg *sdk_struct.MsgStruct) (err error) {
err = c.msgHandleByContentType(msg)
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions open_im_sdk/em.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,6 @@ func (e *emptyAdvancedMsgListener) OnMsgDeleted(message string) {
log.ZWarn(e.ctx, "AdvancedMsgListener is not implemented", nil, "message", message)
}

type emptyBatchMsgListener struct{}

func newEmptyBatchMsgListener() *emptyBatchMsgListener {
return &emptyBatchMsgListener{}
}

func (e *emptyBatchMsgListener) OnRecvNewMessages(messageList string) {

}

func (e *emptyBatchMsgListener) OnRecvOfflineNewMessages(messageList string) {

}

type emptyUserListener struct {
ctx context.Context
}
Expand Down
4 changes: 0 additions & 4 deletions open_im_sdk/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func SetAdvancedMsgListener(listener open_im_sdk_callback.OnAdvancedMsgListener)
listenerCall(UserForSDK.SetAdvancedMsgListener, listener)
}

func SetBatchMsgListener(listener open_im_sdk_callback.OnBatchMsgListener) {
listenerCall(UserForSDK.SetBatchMsgListener, listener)
}

func SetUserListener(listener open_im_sdk_callback.OnUserListener) {
listenerCall(UserForSDK.SetUserListener, listener)

Expand Down
10 changes: 0 additions & 10 deletions open_im_sdk/userRelated.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ type LoginMgr struct {
friendshipListener open_im_sdk_callback.OnFriendshipListener
conversationListener open_im_sdk_callback.OnConversationListener
advancedMsgListener open_im_sdk_callback.OnAdvancedMsgListener
batchMsgListener open_im_sdk_callback.OnBatchMsgListener
userListener open_im_sdk_callback.OnUserListener
signalingListener open_im_sdk_callback.OnSignalingListener
businessListener open_im_sdk_callback.OnCustomBusinessListener
Expand Down Expand Up @@ -140,10 +139,6 @@ func (u *LoginMgr) AdvancedMsgListener() open_im_sdk_callback.OnAdvancedMsgListe
return u.advancedMsgListener
}

func (u *LoginMgr) BatchMsgListener() open_im_sdk_callback.OnBatchMsgListener {
return u.batchMsgListener
}

func (u *LoginMgr) UserListener() open_im_sdk_callback.OnUserListener {
return u.userListener
}
Expand Down Expand Up @@ -215,10 +210,6 @@ func (u *LoginMgr) SetMessageKvInfoListener(messageKvInfoListener open_im_sdk_ca
u.msgKvListener = messageKvInfoListener
}

func (u *LoginMgr) SetBatchMsgListener(batchMsgListener open_im_sdk_callback.OnBatchMsgListener) {
u.batchMsgListener = batchMsgListener
}

func (u *LoginMgr) SetFriendshipListener(friendshipListener open_im_sdk_callback.OnFriendshipListener) {
u.friendshipListener = friendshipListener
}
Expand Down Expand Up @@ -364,7 +355,6 @@ func (u *LoginMgr) setListener(ctx context.Context) {
setListener(ctx, &u.groupListener, u.GroupListener, u.group.SetGroupListener, newEmptyGroupListener)
setListener(ctx, &u.conversationListener, u.ConversationListener, u.conversation.SetConversationListener, newEmptyConversationListener)
setListener(ctx, &u.advancedMsgListener, u.AdvancedMsgListener, u.conversation.SetMsgListener, newEmptyAdvancedMsgListener)
setListener(ctx, &u.batchMsgListener, u.BatchMsgListener, u.conversation.SetBatchMsgListener, nil)
setListener(ctx, &u.businessListener, u.BusinessListener, u.conversation.SetBusinessListener, newEmptyCustomBusinessListener)
}

Expand Down
5 changes: 0 additions & 5 deletions open_im_sdk_callback/callback_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ type OnAdvancedMsgListener interface {
OnRecvOnlineOnlyMessage(message string)
}

type OnBatchMsgListener interface {
OnRecvNewMessages(messageList string)
OnRecvOfflineNewMessages(messageList string)
}

type OnUserListener interface {
OnSelfInfoUpdated(userInfo string)
OnUserStatusChanged(userOnlineStatus string)
Expand Down
7 changes: 0 additions & 7 deletions wasm/event_listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,6 @@ func NewBatchMessageCallback(callback *js.Value) *BatchMessageCallback {
return &BatchMessageCallback{CallbackWriter: NewEventData(callback)}
}

func (b *BatchMessageCallback) OnRecvNewMessages(messageList string) {
b.CallbackWriter.SetEvent(utils.GetSelfFuncName()).SetData(messageList).SendMessage()
}
func (b *BatchMessageCallback) OnRecvOfflineNewMessages(messageList string) {
b.CallbackWriter.SetEvent(utils.GetSelfFuncName()).SetData(messageList).SendMessage()
}

type FriendCallback struct {
CallbackWriter
}
Expand Down
6 changes: 0 additions & 6 deletions wasm/wasm_wrapper/wasm_init_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ func (s *SetListener) setAdvancedMsgListener() {
open_im_sdk.SetAdvancedMsgListener(callback)
}

func (s *SetListener) setBatchMessageListener() {
callback := event_listener.NewBatchMessageCallback(s.commonFunc)
open_im_sdk.SetBatchMsgListener(callback)
}

func (s *SetListener) setFriendListener() {
callback := event_listener.NewFriendCallback(s.commonFunc)
open_im_sdk.SetFriendListener(callback)
Expand Down Expand Up @@ -80,7 +75,6 @@ func (s *SetListener) setCustomBusinessListener() {
func (s *SetListener) SetAllListener() {
s.setConversationListener()
s.setAdvancedMsgListener()
s.setBatchMessageListener()
s.setFriendListener()
s.setGroupListener()
s.setUserListener()
Expand Down