

@classmethod
@gen.coroutine
def SendFollowerAlert(cls, client, user_id, badge, viewpoint, follower, settings, activity):
    'Sends an APNS and/or email alert to the given follower according to his alert settings.'
    if (activity.name == 'add_followers'):
        args_dict = json.loads(activity.json)
        if (user_id not in args_dict['follower_ids']):
            return
    if follower.IsMuted():
        return
    if ((settings.push_alerts is not None) and (settings.push_alerts != AccountSettings.PUSH_NONE)):
        alert_text = (yield AlertManager._FormatAlertText(client, viewpoint, activity))
        if (alert_text is not None):
            if ((follower.viewed_seq + 1) >= viewpoint.update_seq):
                sound = PushNotification.DEFAULT_SOUND
            else:
                sound = None
            viewpoint_id = (viewpoint.viewpoint_id if (viewpoint is not None) else None)
            (yield AlertManager._SendDeviceAlert(client, user_id, viewpoint_id, badge, alert_text, sound=sound))
    if ((sms_count.email_alerts is not None) and (settings.email_alerts != AccountSettings.EMAIL_NONE)):
        alert_email_args = (yield AlertManager._FormatAlertEmail(client, user_id, viewpoint, activity))
        if (alert_email_args is not None):
            try:
                (yield gen.Task(EmailManager.Instance().SendEmail, description=activity.name, **alert_email_args))
            except:
                logging.exception('failed to send alert email user %d', user_id)
    if ((settings.sms_alerts is not None) and (settings.sms_alerts != AccountSettings.SMS_NONE)):
        alert_sms_args = (yield AlertManager._FormatAlertSMS(client, user_id, viewpoint, activity))
        if (alert_sms_args is not None):
            sms_count = (settings.sms_count or 0)
            if (sms_count == AlertManager._SMS_ALERT_LIMIT):
                text = alert_sms_args['text']
                alert_sms_args['text'] = ("You haven't viewed photos shared to you on Viewfinder. Do you want to continue receiving these links? If yes, click: %s" % text[text.rfind('https://'):])
            if (sms_count <= AlertManager._SMS_ALERT_LIMIT):
                try:
                    (yield gen.Task(SMSManager.Instance().SendSMS, description=activity.name, **alert_sms_args))
                except:
                    logging.exception('failed to send alert SMS message user %d', user_id)
            settings.sms_count = (sms_count + 1)
            (yield gen.Task(settings.Update, client))

dataset/ETHPy150Open viewfinderco/viewfinder/backend/op/alert_manager.py AlertManager.SendFollowerAlert/VarMisuse@212/325 `settings`->`sms_count`