mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
audit-log: Move subscription event types to AuditLogEventType enum.
Event types moved: SUBSCRIPTION_CREATED, SUBSCRIPTION_ACTIVATED, SUBSCRIPTION_DEACTIVATED, SUBSCRIPTION_PROPERTY_CHANGED.
This commit is contained in:
committed by
Tim Abbott
parent
56c8cbde1e
commit
10d161638e
@@ -73,7 +73,7 @@ def filter_by_subscription_history(
|
||||
|
||||
event_last_message_id = assert_is_not_none(log_entry.event_last_message_id)
|
||||
|
||||
if log_entry.event_type == RealmAuditLog.SUBSCRIPTION_DEACTIVATED:
|
||||
if log_entry.event_type == AuditLogEventType.SUBSCRIPTION_DEACTIVATED:
|
||||
# If the event shows the user was unsubscribed after
|
||||
# event_last_message_id, we know they must have been
|
||||
# subscribed immediately before the event.
|
||||
@@ -83,8 +83,8 @@ def filter_by_subscription_history(
|
||||
else:
|
||||
break
|
||||
elif log_entry.event_type in (
|
||||
RealmAuditLog.SUBSCRIPTION_ACTIVATED,
|
||||
RealmAuditLog.SUBSCRIPTION_CREATED,
|
||||
AuditLogEventType.SUBSCRIPTION_ACTIVATED,
|
||||
AuditLogEventType.SUBSCRIPTION_CREATED,
|
||||
):
|
||||
initial_msg_count = len(stream_messages)
|
||||
for i, stream_message in enumerate(stream_messages):
|
||||
@@ -104,8 +104,8 @@ def filter_by_subscription_history(
|
||||
# event was a subscription_deactivated then we don't want to create
|
||||
# UserMessage rows for any of the remaining messages.
|
||||
if len(stream_messages) > 0 and stream_subscription_logs[-1].event_type in (
|
||||
RealmAuditLog.SUBSCRIPTION_ACTIVATED,
|
||||
RealmAuditLog.SUBSCRIPTION_CREATED,
|
||||
AuditLogEventType.SUBSCRIPTION_ACTIVATED,
|
||||
AuditLogEventType.SUBSCRIPTION_CREATED,
|
||||
):
|
||||
message_ids.update(stream_message["id"] for stream_message in stream_messages)
|
||||
return sorted(message_ids)
|
||||
@@ -165,9 +165,9 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
# this set changes, the partial index must be updated as well, to
|
||||
# keep this query performant
|
||||
events = [
|
||||
RealmAuditLog.SUBSCRIPTION_CREATED,
|
||||
RealmAuditLog.SUBSCRIPTION_DEACTIVATED,
|
||||
RealmAuditLog.SUBSCRIPTION_ACTIVATED,
|
||||
AuditLogEventType.SUBSCRIPTION_CREATED,
|
||||
AuditLogEventType.SUBSCRIPTION_DEACTIVATED,
|
||||
AuditLogEventType.SUBSCRIPTION_ACTIVATED,
|
||||
]
|
||||
|
||||
# Important: We order first by event_last_message_id, which is the
|
||||
@@ -193,7 +193,7 @@ def add_missing_messages(user_profile: UserProfile) -> None:
|
||||
recipient_ids = []
|
||||
for sub in all_stream_subs:
|
||||
stream_subscription_logs = all_stream_subscription_logs[sub["recipient__type_id"]]
|
||||
if stream_subscription_logs[-1].event_type == RealmAuditLog.SUBSCRIPTION_DEACTIVATED:
|
||||
if stream_subscription_logs[-1].event_type == AuditLogEventType.SUBSCRIPTION_DEACTIVATED:
|
||||
assert stream_subscription_logs[-1].event_last_message_id is not None
|
||||
if (
|
||||
stream_subscription_logs[-1].event_last_message_id
|
||||
|
||||
Reference in New Issue
Block a user