예제 #1
0
  def test_notify_on_comment(self):
    api.entry_add_comment(api.ROOT, 
                          stream='stream/[email protected]/presence',
                          entry='stream/[email protected]/presence/12345',
                          nick='popular', 
                          content='la la la')

    self.exhaust_queue_any()

    # should notify popular and unpopular
    self.assertEqual(len(xmpp.outbox), 2)
예제 #2
0
  def test_notify_on_restricted_comment(self):
    api.subscription_request(api.ROOT, 
                             'stream/[email protected]/comments',
                             'inbox/[email protected]/overview')

    api.entry_add_comment(api.ROOT, 
                          stream='stream/[email protected]/presence',
                          entry='stream/[email protected]/presence/12347',
                          nick='hermit', 
                          content='la la la')

    self.exhaust_queue_any()

    # should notify popular and unpopular
    self.assertEqual(len(xmpp.outbox), 1)
예제 #3
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)
예제 #4
0
  def add_comment(self, from_jid, nick, message):
    jid_ref = api.actor_lookup_im(api.ROOT, from_jid.base())
    if not jid_ref:
      raise exception.ValidationError(
          "You must be signed in to post, please SIGN IN")

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

    nick = clean.nick(nick)
    stream_entry = api.reply_get_cache(sender=nick, 
                                       target=jid_ref.nick, 
                                       service='im')
    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(jid_ref, entry=stream_entry.keyname(),
                          content=message, nick=jid_ref.nick,
                          stream=stream_entry.stream)