

@classmethod
@gen.coroutine
def _FormatConversationSMS(cls, client, recipient_id, viewpoint, activity):
    'Constructs an SMS message which alerts the recipient that they have access to a new\n    conversation, either due to a share_new operation, or to an add_followers operation.\n    The SMS message includes a clickable link to the conversation on the web site.\n    '
    recipient_user = (yield gen.Task(User.Query, client, recipient_id, None))
    if (recipient_user.phone is None):
        raise gen.Return(None)
    identity_key = ('Phone:%s' % recipient_user.phone)
    sharer = (yield gen.Task(User.Query, client, activity.user_id, None))
    sharer_name = AlertManager._GetNameFromUser(sharer, prefer_given_name=recipient_user.IsRegistered())
    viewpoint_url = (yield AlertManager._CreateViewpointURL(client, recipient_user, identity_key, viewpoint, use_short_domain=True))
    sms_list = []
    if viewpoint.title:
        if viewpoint.cover_photo:
            text = '%s shared photos titled "%s". See them on Viewfinder: %s'
            sms_list.append((viewpoint_url % (sharer_name, viewpoint.title, viewpoint_url)))
        text = '%s shared "%s" with you. See it on Viewfinder: %s'
        sms_list.append((text % (sharer_name, viewpoint.title, viewpoint_url)))
        text = '%s shared "%s" on Viewfinder: %s'
        sms_list.append((text % (sharer_name, viewpoint.title, viewpoint_url)))
        if sharer.given_name:
            sms_list.append((text % (sharer.given_name, viewpoint.title, viewpoint_url)))
    if viewpoint.cover_photo:
        text = '%s shared photos on Viewfinder: %s'
        sms_list.append((text % (sharer_name, viewpoint_url)))
    text = '%s shared on Viewfinder: %s'
    sms_list.append((text % (sharer_name, viewpoint_url)))
    if sharer.given_name:
        sms_list.append((text % (sharer.given_name, viewpoint_url)))
    if recipient_user.IsRegistered():
        if viewpoint.cover_photo:
            text = '%s shared photos: %s'
            sms_list.append((text % (sharer_name, viewpoint_url)))
        text = '%s shared: %s'
        sms_list.append((text % (sharer_name, viewpoint_url)))
    remaining = (sms_util.MAX_UTF16_CHARS - len((text % ('', viewpoint_url))))
    name = escape.to_unicode(sharer_name)[:remaining]
    sms_list.append((text % (name, viewpoint_url)))
    for text in sms_list:
        if sms_util.ForceUnicode(text):
            parts = text.rsplit(' ', 1)
            text = '\t'.join(parts)
        if sms_util.IsOneSMSMessage(text):
            break
    assert text, text
    raise gen.Return({
        'number': recipient_user.phone,
        'text': text,
    })

dataset/ETHPy150Open viewfinderco/viewfinder/backend/op/alert_manager.py AlertManager._FormatConversationSMS/VarMisuse@167/370 `text`->`viewpoint_url`