-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Refresh button when branch changes #20511
base: main
Are you sure you want to change the base?
Refresh button when branch changes #20511
Conversation
Could it be that we are generally doing |
This was my thought as well. EDIT: And the |
Refactored the use of SharedWorker per @silverwind s suggestion: Gonna go ahead and remove the WIP label from this, as I think it successfully addresses the original feature request. If there is anything missing from this solution, please let me know! |
First off thanks for the PR. But as far as I can see the current code would inform any logged user of updates to any branch in any repo. This is a huge security hole. At the very least you need to check if the repo can be seen by the user before you push it up their eventstream but its still a huge amount of events that are not needed and this is why I think this problem needs a different approach using websocket to register which repo and branch you're actually interested in. I'm not sure I understand the restructuring that has occurred in the JS (I'm on my phone) but it looks to me like it's still using the eventstream that was originally there. |
I too think we should probably just move everything to websocket, completely removing EventSource. |
Well if you can figure out why the Dom isn't updating in my WIP PR we can get going with that but right now although I have a working websocket that is producing the eventstream events and thus could replace the event source, the events won't update the webpage. |
Maybe I've misunderstood some part of the access model, but isn't this restricted by It should literally only send events to users who have read access to the repo, no? |
With regards to websockets vs SSE, I have no horse in that race - just responding to the original feature request and bounty, which clearly separated the issues: #18427 (comment) Although I'm not entirely certain what pros websockets (a bidirectional, stateful stream) have over SSE here. SSE seems to generally fit the pattern of an original, client-initiated request to setup a unidirectional flow from server to client better. And HTTP/2 makes WS obsolete. Maybe just refactor the EventSource module somewhat server side so you can use other targets than uids (like for instance repos, refnames or orgs). Authorization could then be handled on subscription, when the client initiates the request, or something like that. |
…checks for EventSource dependencies
This was my thought as well. A shared singleton might make more sense and
cut down on the number of concurrent TCP connections.
tors 28 juli 2022 kl. 19:11 skrev silverwind ***@***.***>:
… Could it be that we are generally doing SharedWorker wrong by creating a
separate one for each event type? I think there should likely be only one
that handles all events and distinguish these events by a type property
in the sent data.
—
Reply to this email directly, view it on GitHub
<#20511 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI7Q7LUVFJZBR6CRQH5WDTVWK5LHANCNFSM5422R2MQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
SendMessage via event source will not always work within multiple replication Gitea system. So I think we need a redis based abstract layer to do that. Let's move this to next release to think more. |
What could be done is have all servers being SUBSCRIBEd to a certain redis/kafka/etc channel, and the server that wants to send the message PUBLISHes it to the channel, after which all servers including the sender receive the message and send it on to all their connected and/or affected clients. I think such an approach is universal for server-to-client communication in distributed setups. Ideally this would be done via websockets, thought. |
Would be good if such subscription/event model would be made abstract like we have with queues so that multiple types of subscription providers can be implemented as at least both internal (default) and redis could be used for this. |
Fixes #18427
Had a quick go at the problem. Events are sent at the end of
hook_post_receive.go
, to all users returned byaccess_model.GetRepoReaders()
for the updated repo. The FE event handler filters incoming events by owner, repo and branch. Both changes to the base and head target triggers the reveal of the refresh button.Working good as far as I can tell, some more polish might be needed.
Questions:
notification-worker
for their name? Seemed to be the case in both the currently existing ones, so I followed that example... not sure if it makes sense or not.Please give me your feedback!
EDIT: Removed WIP label