Ejemplo n.º 1
0
  def stop_notifications(self, sender):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    actor_ref = api.settings_change_notify(api.ROOT, sender_ref.nick, sms=False)

    self.send_message([sender], HELP_STOP_NOTIFICATIONS)
Ejemplo n.º 2
0
  def sign_out(self, sender):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    mobile_ref = api.mobile_disassociate(api.ROOT, sender_ref.nick, sender)

    self.send_message([sender], HELP_SIGNED_OUT)
Ejemplo n.º 3
0
    def sign_out(self, sender):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        mobile_ref = api.mobile_disassociate(api.ROOT, sender_ref.nick, sender)

        self.send_message([sender], HELP_SIGNED_OUT)
Ejemplo n.º 4
0
    def channel_post(self, sender, channel_nick, message):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        comment_ref = api.channel_post(sender_ref,
                                       message=message,
                                       nick=sender_ref.nick,
                                       channel=channel_nick)
Ejemplo n.º 5
0
    def stop_notifications(self, sender):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        actor_ref = api.settings_change_notify(api.ROOT,
                                               sender_ref.nick,
                                               sms=False)

        self.send_message([sender], HELP_STOP_NOTIFICATIONS)
Ejemplo n.º 6
0
  def channel_post(self, sender, channel_nick, message):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    comment_ref = api.channel_post(
        sender_ref,
        message=message,
        nick=sender_ref.nick,
        channel=channel_nick
    )
Ejemplo n.º 7
0
    def channel_join(self, sender, nick):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)
        channel = clean.channel(nick)

        try:
            api.channel_join(sender_ref, sender_ref.nick, channel)
            self.send_message(
                (sender, ), "%s joined %s" % (sender_ref.display_nick(), nick))

        except:
            self.send_message((sender, ), "Failed to join %s" % nick)
Ejemplo n.º 8
0
  def confirm(self, sender):
    """ confirm something if something needs to be confirmed
    
    otherwise, just post the message
    """

    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    if sender_ref.extra.get('sms_double_opt_in', None):
      api.mobile_confirm_doubleoptin(api.ROOT, sender_ref.nick)

    self.start_notifications(sender)
Ejemplo n.º 9
0
  def channel_part(self, sender, nick):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)
    channel = clean.channel(nick)

    try:
      api.channel_part(sender_ref, sender_ref.nick, channel)
      self.send_message((sender,),
                        "%s left %s" % (sender_ref.display_nick(), nick))

    except:
      self.send_message((sender,),
                        "Failed to leave %s" % nick)
Ejemplo n.º 10
0
  def actor_add_contact(self, sender, nick):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)
    clean_nick = clean.nick(nick)

    try:
      api.actor_add_contact(sender_ref, sender_ref.nick, clean_nick)
      self.send_message((sender,),
                        "%s followed %s" % (sender_ref.display_nick(), nick))

    except:
      self.send_message((sender,),
                        "Failed to follow %s" % nick)
Ejemplo n.º 11
0
    def confirm(self, sender):
        """ confirm something if something needs to be confirmed
    
    otherwise, just post the message
    """

        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        if sender_ref.extra.get('sms_double_opt_in', None):
            api.mobile_confirm_doubleoptin(api.ROOT, sender_ref.nick)

        self.start_notifications(sender)
Ejemplo n.º 12
0
    def actor_remove_contact(self, sender, nick):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)
        clean_nick = clean.nick(nick)

        try:
            api.actor_remove_contact(sender_ref, sender_ref.nick, clean_nick)
            self.send_message(
                (sender, ),
                "%s stopped following %s" % (sender_ref.dispaly_nick(), nick))

        except:
            self.send_message((sender, ), "Failed to stop following %s" % nick)
Ejemplo n.º 13
0
    def start_notifications(self, sender):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        if sender_ref.extra.get('sms_double_opt_in', None):
            message = ' '.join([HELP_DOUBLE_OPT_IN, HELP_CHARGES])
            self.send_message([sender], message)
            return

        actor_ref = api.settings_change_notify(api.ROOT,
                                               sender_ref.nick,
                                               sms=True)

        message = ' '.join([HELP_START_NOTIFICATIONS, HELP_CHARGES])

        self.send_message([sender], message)
Ejemplo n.º 14
0
  def start_notifications(self, sender):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    if sender_ref.extra.get('sms_double_opt_in', None):
      message = ' '.join([HELP_DOUBLE_OPT_IN,
                          HELP_CHARGES])
      self.send_message([sender], message)
      return

    actor_ref = api.settings_change_notify(api.ROOT, sender_ref.nick, sms=True)

    message = ' '.join([HELP_START_NOTIFICATIONS,
                        HELP_CHARGES])

    self.send_message([sender], message)
Ejemplo n.º 15
0
  def add_comment(self, sender, nick, message):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if not sender_ref:
      raise exception.ValidationError(HELP_SIGN_IN)

    logging.debug("comment: %s %s %s", nick, sender_ref.nick, message)

    nick = clean.nick(nick)
    stream_entry = api.reply_get_cache(sender=nick,
                                       target=sender_ref.nick,
                                       service='sms')
    if not stream_entry:
      # Well, or memcache timed it out...  Or we crashed... Or... Or...
      raise exception.ValidationError(
          'The message to which you tried to respond doesn\'t exist')

    api.entry_add_comment(sender_ref, entry=stream_entry.keyname(),
                          content=message, nick=sender_ref.nick,
                          stream=stream_entry.stream)
Ejemplo n.º 16
0
    def sign_in(self, sender, nick, password):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if sender_ref:
            raise exception.ValidationError(
                "You are already signed in, please SIGN OUT first")

        user_ref = user.authenticate_user_login(nick, password)
        if not user_ref:
            raise exception.ValidationError(
                "Username or password is incorrect")

        mobile_ref = api.mobile_associate(api.ROOT, user_ref.nick, sender)

        # if they need to double opt in send them the confirmation message
        welcome = ' '.join([
            HELP_WELCOME_NICK % user_ref.display_nick(), HELP_POST, HELP_START,
            HELP_CHARGES
        ])

        self.send_message([sender], welcome)
Ejemplo n.º 17
0
  def sign_in(self, sender, nick, password):
    sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
    if sender_ref:
      raise exception.ValidationError(
          "You are already signed in, please SIGN OUT first")

    user_ref = user.authenticate_user_login(nick, password)
    if not user_ref:
      raise exception.ValidationError("Username or password is incorrect")

    mobile_ref = api.mobile_associate(api.ROOT, user_ref.nick, sender)

    # if they need to double opt in send them the confirmation message
    welcome = ' '.join([HELP_WELCOME_NICK % user_ref.display_nick(),
                         HELP_POST,
                         HELP_START,
                         HELP_CHARGES
                         ])

    self.send_message([sender], welcome)
Ejemplo n.º 18
0
    def add_comment(self, sender, nick, message):
        sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
        if not sender_ref:
            raise exception.ValidationError(HELP_SIGN_IN)

        logging.debug("comment: %s %s %s", nick, sender_ref.nick, message)

        nick = clean.nick(nick)
        stream_entry = api.reply_get_cache(sender=nick,
                                           target=sender_ref.nick,
                                           service='sms')
        if not stream_entry:
            # Well, or memcache timed it out...  Or we crashed... Or... Or...
            raise exception.ValidationError(
                'The message to which you tried to respond doesn\'t exist')

        api.entry_add_comment(sender_ref,
                              entry=stream_entry.keyname(),
                              content=message,
                              nick=sender_ref.nick,
                              stream=stream_entry.stream)
Ejemplo n.º 19
0
 def post(self, sender, message):
   sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
   if not sender_ref:
     raise exception.ValidationError(HELP_SIGN_IN)
   entry_ref = api.post(sender_ref, nick=sender_ref.nick, message=message)
Ejemplo n.º 20
0
 def post(self, sender, message):
     sender_ref = api.actor_lookup_mobile(api.ROOT, sender)
     if not sender_ref:
         raise exception.ValidationError(HELP_SIGN_IN)
     entry_ref = api.post(sender_ref, nick=sender_ref.nick, message=message)