Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ replays: 0007_organizationmember_replay_access

seer: 0007_add_extras_to_nightshiftrun

sentry: 1070_increase_integration_external_id_length
sentry: 1071_add_broadcast_sync_locked

social_auth: 0003_social_auth_json_field

Expand Down
16 changes: 16 additions & 0 deletions src/sentry/api/endpoints/broadcast_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

logger = logging.getLogger("sentry")

# Broadcast fields refreshed by the getsentry changelog sync job. Editing any of
# these on a changelog-sourced broadcast locks it from future auto-updates.
SYNC_MANAGED_FIELDS = frozenset(
{"title", "message", "link", "media_url", "category", "is_active", "date_expires"}
)


from rest_framework.request import Request
from rest_framework.response import Response
Expand Down Expand Up @@ -93,8 +99,18 @@ def put(self, request: Request, broadcast: Broadcast) -> Response:
update_kwargs["media_url"] = result["mediaUrl"]
if result.get("category"):
update_kwargs["category"] = result["category"]
if result.get("syncLocked") is not None:
update_kwargs["sync_locked"] = result["syncLocked"]

if update_kwargs:
if (
broadcast.upstream_id
and not broadcast.sync_locked
and "sync_locked" not in update_kwargs
and SYNC_MANAGED_FIELDS & update_kwargs.keys()
):
update_kwargs["sync_locked"] = True

with transaction.atomic(using=router.db_for_write(Broadcast)):
broadcast.update(**update_kwargs)
logger.info(
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/api/serializers/models/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ def serialize(self, obj, attrs, user, **kwargs):
context = super().serialize(obj, attrs, user)
context["userCount"] = attrs["user_count"]
context["createdBy"] = obj.created_by_id.email if obj.created_by_id else None
context["upstreamId"] = obj.upstream_id
context["syncLocked"] = obj.sync_locked
return context
1 change: 1 addition & 0 deletions src/sentry/api/validators/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ class AdminBroadcastValidator(BroadcastValidator):
cta = serializers.CharField(max_length=256, required=False)
mediaUrl = serializers.URLField(required=False)
category = serializers.ChoiceField(choices=BROADCAST_CATEGORIES, required=False)
syncLocked = serializers.BooleanField(required=False)
33 changes: 33 additions & 0 deletions src/sentry/migrations/1071_add_broadcast_sync_locked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.2.12 on 2026-04-20 00:00

from django.db import migrations, models

from sentry.new_migrations.migrations import CheckedMigration


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "1070_increase_integration_external_id_length"),
]

operations = [
migrations.AddField(
model_name="broadcast",
name="sync_locked",
field=models.BooleanField(default=False, db_default=False),
),
]
4 changes: 4 additions & 0 deletions src/sentry/models/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class Broadcast(Model):
media_url = models.URLField(null=True, blank=True)
category = models.CharField(choices=BROADCAST_CATEGORIES, max_length=32, null=True, blank=True)
created_by_id = FlexibleForeignKey("sentry.User", null=True, on_delete=models.SET_NULL)
# When True, the hourly changelog sync job in getsentry skips updates to this
# broadcast. Flipped automatically when an admin edits a sync-managed field
# on a changelog-sourced broadcast; can be cleared to re-enable sync.
sync_locked = models.BooleanField(default=False, db_default=False)

class Meta:
app_label = "sentry"
Expand Down
Loading
Loading