Skip to content

Commit

Permalink
Remove unnecessary method to create quick_replies outgoing
Browse files Browse the repository at this point in the history
  • Loading branch information
teehamaral committed Nov 27, 2017
1 parent 80e3a8e commit d7ac767
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions temba/msgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,19 +1429,6 @@ def evaluate_template(cls, text, context, org=None, url_encode=False, partial_va
# returns tuple of output and errors
return evaluate_template(text, context, url_encode, partial_vars)

@classmethod
def get_outgoing_metadata(cls, quick_replies, expressions_context, contact, org, channel):
for counter, reply in enumerate(quick_replies):
(text, errors) = Msg.evaluate_template(reply, expressions_context, org=org)
if text:
if contact.is_test:
quick_replies[counter] = text
else:
channel_type = Channel.get_type_from_code(channel.channel_type)
quick_replies[counter] = text[:channel_type.quick_reply_text_size]

return quick_replies

@classmethod
def create_outgoing(cls, org, user, recipient, text, broadcast=None, channel=None, high_priority=False,
created_on=None, response_to=None, expressions_context=None, status=PENDING, insert_object=True,
Expand Down Expand Up @@ -1554,7 +1541,14 @@ def create_outgoing(cls, org, user, recipient, text, broadcast=None, channel=Non

metadata = None
if quick_replies:
quick_replies = Msg.get_outgoing_metadata(quick_replies, expressions_context, contact, org, channel)
for counter, reply in enumerate(quick_replies):
(value, errors) = Msg.evaluate_template(text=reply, context=expressions_context, org=org)
if value:
if contact.is_test:
quick_replies[counter] = value
else:
channel_type = Channel.get_type_from_code(channel.channel_type)
quick_replies[counter] = value[:channel_type.quick_reply_text_size]
metadata = json.dumps(dict(quick_replies=quick_replies))

msg_args = dict(contact=contact,
Expand Down

0 comments on commit d7ac767

Please sign in to comment.