-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix handling of logout event #15323
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
Fix handling of logout event #15323
Conversation
It appears that there is a slight bug in the handling of the data of logout event - the javascript should be testing the data field of the data field for the logout instruction. Signed-off-by: Andrew Thornton <[email protected]>
Don't you need to |
Don't appear to need it. Have you found that you do need it? Looking again at this - the data is not JSON data so no it does not need to be parsed no.
Which method? |
Just a few lines above gitea/web_src/js/features/notification.js Line 65 in 4a68ed4
which then does gitea/web_src/js/features/notification.js Line 23 in 4a68ed4
And finally it accesses title-cased gitea/web_src/js/features/notification.js Line 32 in 4a68ed4
I think this requires more refactoring to be clear. I would |
the data from a logout event is simply text. So this is correct as it stands. |
The only way this can work is that in the event |
No you've got it wrong. Why don't you test it. |
That's something I've meaning to ask. How does one generate fake eventsource events on the server? Is there some convenient way to do so? |
there's no built in way of doing this. All of the events are created in gitea/routers/events/events.go Lines 35 to 40 in 426ebbf
is the simplest example. In this case the important event is: gitea/routers/events/events.go Lines 130 to 134 in 426ebbf
Which will simply be emitted as:
The eventsource will then send a js object event: {
...
"data": {
"type": "logout",
"data": "here",
}
} which gets pushed to the workers as an "event": {
"type": "logout",
"data": {
"type": "logout",
"data": "here",
},
} The double wrapping of the data is an unfortunate consequence of the way events are passed around js - this could be stopped by changing: gitea/web_src/js/features/eventsource.sharedworker.js Lines 50 to 54 in 426ebbf
L53 to In the case of notification events the data is []byte of json data in the Event struct. |
I need to move the stopwatches query out of the event stream and instead consider a similar db query to how we do the notification stream but I've not had the inclination do that yet. |
I think I understand now. My assumption was that the inner Event{
Name: "notification-count",
Data: uidCount,
}
Event{
Name: "logout",
Data: "here",
}
# uidCount
type UserIDCount struct {
UserID int64
Count int64
} I did not find where the JSON serialization happens but it must be somewhere. Refactoring this |
Backport go-gitea#15323 It appears that there is a slight bug in the handling of the data of logout event - the javascript should be testing the data field of the data field for the logout instruction. Signed-off-by: Andrew Thornton <[email protected]>
Backport #15323 It appears that there is a slight bug in the handling of the data of logout event - the javascript should be testing the data field of the data field for the logout instruction. Signed-off-by: Andrew Thornton <[email protected]>
It appears that there is a slight bug in the handling of the data of logout event -
the javascript should be testing the data field of the data field for the logout
instruction.
Signed-off-by: Andrew Thornton [email protected]