Skip to content

Conversation

@krishukr
Copy link

(cherry picked from commit 9c99a84)

Description

Background: My friends complained that I always show online but don’t read messages in time and confused. I discovered that Cinny keeps setting my account’s presence status to online even when I put the client in the background.

Apparently, Cinny sent /sync requests to Homeserver even in the background, which is reasonable for a client to catch up with events. However, this misled the HS to believe that the user was online.

Investigating Matrix Client-Server API specification, I discovered that an user's presence status is inferred by Homeserver based on API activities or be explicitly set by Client via /presence/{userId}/status or implicitly set along with /sync requests using parameter set_presence. matrix-js-sdk provides both methods setPresence and setSyncPresence.

Ideally, we choose to use setSyncPresence. Because even if presence status were set via /presence, /sync API calls that keep running in the background still confuse Homeserver to consider the user being online. Furthermore, this way won't override possible presence status from other clients.

After this change, a) when the Cinny window is focused, the presence is online, b) when the Cinny window is not focused and running in background, the presence is unavailable, c) when the Cinny isn't running, the presence is offline.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@github-actions
Copy link

github-actions bot commented Jul 15, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@krishukr
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

ajbura added a commit to cinnyapp/cla that referenced this pull request Jul 15, 2025
Copy link
Member

@ajbura ajbura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, Thanks. The changes mostly look good, but i could not able to test them as my server doesn't have presence feature enabled. Could you recommend any server which does that and have open registration?

Also it might be a good idea to only setSyncPresence if server actually support it.

@github-actions
Copy link

Preview: https://2395--pr-cinny.netlify.app
⚠️ Exercise caution. Use test accounts. ⚠️

@krishukr
Copy link
Author

Hey, Thanks. The changes mostly look good, but i could not able to test them as my server doesn't have presence feature enabled. Could you recommend any server which does that and have open registration?

Also it might be a good idea to only setSyncPresence if server actually support it.

Thanks for responding, I am new to the Matrix Ecosystem and not familiar with it, so please do point it out if I am wrong.

I personally use Synapse as my HS. Which, if I recollect correctly, is also the HS for matrix.org.

As it for reproducing, my guess is that you are using Cinny as your client, which does not display presence of users. You can try Element.

But the easiest way is to run a curl command in shell:

curl -X GET https://<YOUR_HOMESERVER>/_matrix/client/v3/presence/<ANY_USER_YOU_LIKE>/status \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'

Access token can be get in Cinny's Settings > Developer Tools. Enable Developer Tools first, and copy Access Token. This API is documented in Matrix Client-Server API spec.

Here I also quote from Matrix spec:

Modules are strictly defined within this specification and should not be mistaken for experimental extensions or optional features. A compliant server implementation MUST support all modules and supporting specification[.]

Where Presence defined as a module, most popular matrix server should implemented this module, i.e., Cinny should properly handle presence status accordingly.

Setting presence status along with a /sync call is also in spec.

@ajbura
Copy link
Member

ajbura commented Jul 18, 2025

yeah synapse do support presence but matrix-client.matrix.org has this feature disabled so everyone remain 'offline' for me, that is why i am not able test it on matrix.org and wondering if there are any server with open registration for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants