Extract get_stream_recipient().

Do you call get_recipient(Recipient.STREAM, stream_id) or
get_recipient(stream_id, Recipient.STREAM)?  I could never
remember, and it was not very type safe, since both parameters
are integers.
This commit is contained in:
Steve Howell
2017-10-28 11:26:11 -07:00
committed by Tim Abbott
parent b7a9068724
commit a28841e8aa
16 changed files with 45 additions and 41 deletions

View File

@@ -25,7 +25,7 @@ from zerver.worker import queue_processors
from zerver.lib.actions import (
check_send_message, create_stream_if_needed, bulk_add_subscriptions,
get_display_recipient, bulk_remove_subscriptions
get_display_recipient, bulk_remove_subscriptions, get_stream_recipient,
)
from zerver.models import (
@@ -240,7 +240,7 @@ def most_recent_message(user_profile):
def get_subscription(stream_name, user_profile):
# type: (Text, UserProfile) -> Subscription
stream = get_stream(stream_name, user_profile.realm)
recipient = get_recipient(Recipient.STREAM, stream.id)
recipient = get_stream_recipient(stream.id)
return Subscription.objects.get(user_profile=user_profile,
recipient=recipient, active=True)