Example #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)
Example #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)
Example #3
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
    )
Example #4
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)
Example #5
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)
Example #6
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)
Example #7
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)
Example #8
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)
Example #9
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)
Example #10
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)