Exemple #1
0
    def title(self):
        """ build a title for this entry, for a presence entry it will just be
    the title, but for a comment it will look like:

    Comment from [commenter nick] on [entry title] by [nick]

    Comment from [commenter nick] on [entry title] by [nick] to #[channel name]
    """

        if not self.is_comment():
            return self.extra.get('title')

        template = "Comment from %(actor)s on %(entry_title)s by %(entry_actor)s"
        actor = _get_actor_urlnick_from_nick(self.actor)
        entry_title = self.extra.get('entry_title')
        entry_actor = _get_actor_urlnick_from_nick(
            self.extra.get('entry_actor'))
        entry_owner_nick = util.get_user_from_topic(self.entry)
        entry_type = _get_actor_type_from_nick(entry_owner_nick)

        v = {
            'actor': actor,
            'entry_title': entry_title,
            'entry_actor': entry_actor,
        }

        if entry_type == 'channel':
            template += ' to #%(channel)s'
            channel = _get_actor_urlnick_from_nick(entry_owner_nick)
            v['channel'] = channel

        return template % v
Exemple #2
0
  def title(self):
    """ build a title for this entry, for a presence entry it will just be
    the title, but for a comment it will look like:

    Comment from [commenter nick] on [entry title] by [nick]

    Comment from [commenter nick] on [entry title] by [nick] to #[channel name]
    """

    if not self.is_comment():
      return self.extra.get('title')

    template = "Comment from %(actor)s on %(entry_title)s by %(entry_actor)s"
    actor = _get_actor_urlnick_from_nick(self.actor)
    entry_title = self.extra.get('entry_title')
    entry_actor = _get_actor_urlnick_from_nick(self.extra.get('entry_actor'))
    entry_owner_nick = util.get_user_from_topic(self.entry)
    entry_type = _get_actor_type_from_nick(entry_owner_nick)

    v = {'actor': actor,
         'entry_title': entry_title,
         'entry_actor': entry_actor,
         }

    if entry_type == 'channel':
      template += ' to #%(channel)s'
      channel = _get_actor_urlnick_from_nick(entry_owner_nick)
      v['channel'] = channel

    return template % v
Exemple #3
0
 def test_get_user_from_topic(self):
   topics = [('*****@*****.**', 'inbox/[email protected]/presence'),
             ('*****@*****.**', 'inbox/[email protected]/overview'),
             ('*****@*****.**', 'stream/[email protected]/presence/12345'),
             (None, 'stream//presence'),
             (None, 'stream/something/else'),
             ('*****@*****.**', 'crazy/[email protected]/dddfff$$%%///'),
             ('asdad@asdasd@asdasd', 'multi/asdad@asdasd@asdasd/cllad/asdff')]
   for t in topics:
     self.assertEqual(util.get_user_from_topic(t[1]), t[0], t[1])
Exemple #4
0
 def test_get_user_from_topic(self):
     topics = [
         ('*****@*****.**', 'inbox/[email protected]/presence'),
         ('*****@*****.**', 'inbox/[email protected]/overview'),
         ('*****@*****.**', 'stream/[email protected]/presence/12345'),
         (None, 'stream//presence'), (None, 'stream/something/else'),
         ('*****@*****.**',
          'crazy/[email protected]/dddfff$$%%///'),
         ('asdad@asdasd@asdasd', 'multi/asdad@asdasd@asdasd/cllad/asdff')
     ]
     for t in topics:
         self.assertEqual(util.get_user_from_topic(t[1]), t[0], t[1])
Exemple #5
0
  def check_inboxes_for_entry(self, entry_ref, expected):
    inboxes = api.inbox_get_all_for_entry(api.ROOT,
                                          entry_ref.stream,
                                          entry_ref.uuid,
                                          entry_ref.entry)

    #self.assertEqual(len(inboxes), len(set(inboxes)), 'duplicates: %s' % inboxes)
    self.assertSetEqual(set(expected), set(inboxes))
    for inbox in inboxes:
      actor_ref = api.actor_get(api.ROOT, util.get_user_from_topic(inbox))
      if not api.entry_get_safe(actor_ref, entry_ref.keyname()):
        self.fail('An entry not visible by a user was added to their inbox')
    return inboxes
Exemple #6
0
    def check_inboxes_for_entry(self, entry_ref, expected):
        inboxes = api.inbox_get_all_for_entry(api.ROOT, entry_ref.stream,
                                              entry_ref.uuid, entry_ref.entry)

        #self.assertEqual(len(inboxes), len(set(inboxes)), 'duplicates: %s' % inboxes)
        self.assertSetEqual(set(expected), set(inboxes))
        for inbox in inboxes:
            actor_ref = api.actor_get(api.ROOT,
                                      util.get_user_from_topic(inbox))
            if not api.entry_get_safe(actor_ref, entry_ref.keyname()):
                self.fail(
                    'An entry not visible by a user was added to their inbox')
        return inboxes
Exemple #7
0
 def entry_actor(self):
   if self.entry:
     return util.get_user_from_topic(self.entry)
   return None
Exemple #8
0
 def entry_actor(self):
     if self.entry:
         return util.get_user_from_topic(self.entry)
     return None
Exemple #9
0
 def get_actors_for_inboxes(self, inboxes):
   subscribers = [util.get_user_from_topic(inbox) for inbox in inboxes]
   subscribers = list(set(subscribers))
   subscribers_ref = api.actor_get_actors(api.ROOT, subscribers)
   subscribers_ref = [v for k, v in subscribers_ref.iteritems() if v]
   return subscribers_ref
Exemple #10
0
 def get_actors_for_inboxes(self, inboxes):
     subscribers = [util.get_user_from_topic(inbox) for inbox in inboxes]
     subscribers = list(set(subscribers))
     subscribers_ref = api.actor_get_actors(api.ROOT, subscribers)
     subscribers_ref = [v for k, v in subscribers_ref.iteritems() if v]
     return subscribers_ref