mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
onboarding_steps: Send event on commit in mark onboarding_step as read.
Earlier, we were using 'send_event' in 'do_mark_onboarding_step_as_read' which can lead to a situation, if any db operation is added after the 'send_event' in future, where we enqueue events but the action function fails at a later stage. Events should not be sent until we know we're not rolling back. Fixes part of #30489.
This commit is contained in:
committed by
Tim Abbott
parent
b287efce43
commit
567615a484
@@ -1,9 +1,12 @@
|
|||||||
|
from django.db import transaction
|
||||||
|
|
||||||
from zerver.lib.onboarding_steps import get_next_onboarding_steps
|
from zerver.lib.onboarding_steps import get_next_onboarding_steps
|
||||||
from zerver.models import OnboardingStep, UserProfile
|
from zerver.models import OnboardingStep, UserProfile
|
||||||
from zerver.tornado.django_api import send_event
|
from zerver.tornado.django_api import send_event_on_commit
|
||||||
|
|
||||||
|
|
||||||
|
@transaction.atomic(durable=True)
|
||||||
def do_mark_onboarding_step_as_read(user: UserProfile, onboarding_step: str) -> None:
|
def do_mark_onboarding_step_as_read(user: UserProfile, onboarding_step: str) -> None:
|
||||||
OnboardingStep.objects.get_or_create(user=user, onboarding_step=onboarding_step)
|
OnboardingStep.objects.get_or_create(user=user, onboarding_step=onboarding_step)
|
||||||
event = dict(type="onboarding_steps", onboarding_steps=get_next_onboarding_steps(user))
|
event = dict(type="onboarding_steps", onboarding_steps=get_next_onboarding_steps(user))
|
||||||
send_event(user.realm, event, [user.id])
|
send_event_on_commit(user.realm, event, [user.id])
|
||||||
|
|||||||
Reference in New Issue
Block a user