Sometimes`get_notification_item` for invite notifications returns `403 FORBIDDEN` error
Here is a log of the error. This does not happen consistently, but only some times, and only for invite notifications. Here is a log of the error:
the server returned an error: [403 / M_FORBIDDEN] User @mauro.romito:matrix.org not in room !rWncTinLEtLXDzUGge:element.io, and room previews are disabled
Seems that this happens when trying to fetch the room given its room id from the client in the function.
It looks like it's trying to make a request for the room, but afaik it's not possible to make any request for invited rooms that don't share their history before the user joins it. It's only possible to use the invited state of the sync response
But it's weird, sometimes it does work though, also we can't rely for now on the sync response, maybe with the changes in the notification sliding sync, we could instead? @bnjbvr
By the way, getting the room is all local so it wouldn't fail like that. This happens actually when trying to fetch the event from the homeserver with its event ID.
You should probably compare the m.room.history_visibility state event in rooms where it works and in rooms where it doesn't work. If sometimes it works and sometimes it doesn't work in the same room that would be weird.
indeed it does not work and sometimes does work for the same room, and I have one room where I invite myself and disinvite costantly to test notifications, but the room stays the same.
Most of the time sit works fine but sometimes I get the 403 error, or... sometimes the name of the room is Empty Room
Is there a way to know exactly on which method this is returned? Looking at the code there are 2 places where it could make a request:
- When fetching the event from the server: https://github.com/matrix-org/matrix-rust-sdk/blob/6b45749e17ce065534d7561964e779af673426cc/bindings/matrix-sdk-ffi/src/notification.rs#L38
- If the room state is not set to Invited, it will try to sync the members as part of a call to
get_member: https://github.com/matrix-org/matrix-rust-sdk/blob/6b45749e17ce065534d7561964e779af673426cc/bindings/matrix-sdk-ffi/src/notification.rs#L51
So if you are doing it with the same room where you join and leave constantly, it is possible that the room is still in the wrong state and it tries to fetch all members, which is what fails. Which could explain both of your issues.
@Velin92 I can try to take a look but I think it's unrelated to the loop itself. It's not impossible that I'm going to entirely revamp the FFI notification API so that you get a listener on new notifications, with the message content (or errors we may run into while decrypting).
@Velin92 I can try to take a look but I think it's unrelated to the loop itself. It's not impossible that I'm going to entirely revamp the FFI notification API so that you get a listener on new notifications, with the message content (or errors we may run into while decrypting).
oh yeah that would be great