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

[BUG] in SetUserStatus Method: Incorrect Handling of Offline Status #2593

Open
zhaolibo1989 opened this issue Sep 5, 2024 · 0 comments
Open
Assignees
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@zhaolibo1989
Copy link

OpenIM Server Version

3.8.0

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

Description:

Hello,

I've noticed a potential bug in the SetUserStatus method within the user server logic. The method is supposed to handle both online and offline status updates for users, but it appears to incorrectly handle the offline status.

Current Behavior:

  • The method initializes online and offline slices to store platform IDs for online and offline statuses respectively.
  • However, regardless of whether the status is set to constant.Online or constant.Offline, the platform ID is only added to the online slice. This leads to a failure in correctly updating the offline status in the SetUserOnline method.

Expected Behavior:

  • The method should correctly assign the platform ID to either the online or offline slice based on the status provided in the request.
  • The offline slice should be populated when the status is constant.Offline, allowing the SetUserOnline method to accurately reflect the user's offline status in Redis.

Steps to Reproduce:

  1. Call the SetUserStatus method with a status of constant.Offline.
  2. Observe that the platform ID is added to the online slice instead of the offline slice.

Proposed Fix:

  • Update the switch case to correctly assign the platform ID to the offline slice when the status is constant.Offline.
switch req.Status {
case constant.Online:
    online = []int32{req.PlatformID}
case constant.Offline:
    offline = []int32{req.PlatformID}
}

Additional Information:

  • It seems like a simple oversight, but it's crucial for the functionality of the user status management.
  • I've reviewed the related SetUserOnline method and confirmed that it relies on the correct assignment of platform IDs to the online and offline slices.

Thank you for considering this bug fix. I believe addressing this will improve the accuracy of user status updates in our system.

Screenshots Link

func (s *userServer) SetUserStatus:
https://github.com/openimsdk/open-im-server/blob/v3.8.0/internal/rpc/user/online.go#L53

@zhaolibo1989 zhaolibo1989 added the bug Categorizes issue or PR as related to a bug. label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants