mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 04:05:42 +01:00
Merge pull request '[BUG] Make logout event non-blocking' (#4938) from gusted/forgejo-non-blocking-logout into forgejo
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4938 Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
da7f3ac6f5
3 changed files with 1 additions and 20 deletions
|
@ -77,13 +77,3 @@ func (m *Manager) SendMessage(uid int64, message *Event) {
|
||||||
messenger.SendMessage(message)
|
messenger.SendMessage(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessageBlocking sends a message to a particular user
|
|
||||||
func (m *Manager) SendMessageBlocking(uid int64, message *Event) {
|
|
||||||
m.mutex.Lock()
|
|
||||||
messenger, ok := m.messengers[uid]
|
|
||||||
m.mutex.Unlock()
|
|
||||||
if ok {
|
|
||||||
messenger.SendMessageBlocking(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,12 +66,3 @@ func (m *Messenger) SendMessage(message *Event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessageBlocking sends the message to all registered channels and ensures it gets sent
|
|
||||||
func (m *Messenger) SendMessageBlocking(message *Event) {
|
|
||||||
m.mutex.Lock()
|
|
||||||
defer m.mutex.Unlock()
|
|
||||||
for i := range m.channels {
|
|
||||||
m.channels[i] <- message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ func HandleSignOut(ctx *context.Context) {
|
||||||
// SignOut sign out from login status
|
// SignOut sign out from login status
|
||||||
func SignOut(ctx *context.Context) {
|
func SignOut(ctx *context.Context) {
|
||||||
if ctx.Doer != nil {
|
if ctx.Doer != nil {
|
||||||
eventsource.GetManager().SendMessageBlocking(ctx.Doer.ID, &eventsource.Event{
|
eventsource.GetManager().SendMessage(ctx.Doer.ID, &eventsource.Event{
|
||||||
Name: "logout",
|
Name: "logout",
|
||||||
Data: ctx.Session.ID(),
|
Data: ctx.Session.ID(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue