muting: Record DateTime when a Topic is muted.

This includes the necessary migration to add
the date_muted field to the MutedTopic class
and populates it with a hard coded value.
This commit is contained in:
Ryan Rehman
2020-01-17 20:31:00 +05:30
committed by Tim Abbott
parent e4259d48a5
commit 3dc7d60ffe
8 changed files with 65 additions and 7 deletions

View File

@@ -5286,8 +5286,11 @@ def do_set_alert_words(user_profile: UserProfile, alert_words: List[str]) -> Non
set_user_alert_words(user_profile, alert_words)
notify_alert_words(user_profile, alert_words)
def do_mute_topic(user_profile: UserProfile, stream: Stream, recipient: Recipient, topic: str) -> None:
add_topic_mute(user_profile, stream.id, recipient.id, topic)
def do_mute_topic(user_profile: UserProfile, stream: Stream, recipient: Recipient, topic: str,
date_muted: Optional[datetime.datetime]=None) -> None:
if date_muted is None:
date_muted = timezone_now()
add_topic_mute(user_profile, stream.id, recipient.id, topic, date_muted)
event = dict(type="muted_topics", muted_topics=get_topic_mutes(user_profile))
send_event(user_profile.realm, event, [user_profile.id])