Example #1
0
  def test_task_post_process_any(self):
    """ test that api.post creates a task and additional calls resume
    """
    nick = '*****@*****.**'
    uuid = 'HOWNOW'
    message = 'BROWNCOW'

    actor_ref = api.actor_get(api.ROOT, nick)

    # DROP
    old_max = api.MAX_FOLLOWERS_PER_INBOX
    api.MAX_FOLLOWERS_PER_INBOX = 1

    entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
    self.assertEqual(entry_ref.extra['title'], message)
    
    # make sure we can repeat
    two_entry_ref = api.post(actor_ref, nick=nick, uuid=uuid, message=message)
    self.assertEqual(entry_ref.uuid, two_entry_ref.uuid)
    
    # and that task_process_actor works
    task_more = api.task_process_any(api.ROOT)
    self.assert_(task_more)

    # and run out the queue
    task_more = api.task_process_any(api.ROOT)
    task_more = api.task_process_any(api.ROOT)
    task_more = api.task_process_any(api.ROOT)
    task_more = api.task_process_any(api.ROOT)

    def _nope():
      task_more = api.task_process_any(api.ROOT)
    
    self.assertRaises(exception.ApiNoTasks, _nope)

    api.MAX_FOLLOWERS_PER_INBOX = old_max  

    pass
Example #2
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)
Example #3
0
  def test_notify_on_post(self):
    api.post(api.ROOT, nick='popular', message='la la la')
    self.exhaust_queue('popular')

    # should notify popular and unpopular
    self.assertEqual(len(xmpp.outbox), 2)
Example #4
0
def join_join(request):
    if request.user:
        raise exception.AlreadyLoggedInException()

    redirect_to = request.REQUEST.get("redirect_to", "/")

    # get the submitted vars
    nick = request.REQUEST.get("nick", "")
    first_name = request.REQUEST.get("first_name", "")
    last_name = request.REQUEST.get("last_name", "")
    email = request.REQUEST.get("email", "")
    password = request.REQUEST.get("password", "")
    confirm = request.REQUEST.get("confirm", "")
    hide = request.REQUEST.get("hide", "")

    if request.POST:
        try:
            # TODO validate
            params = util.query_dict_to_keywords(request.POST)

            if hide:
                params["privacy"] = 2

            validate.email(email)
            if not mail.is_allowed_to_send_email_to(email):
                raise exception.ValidationError("Cannot send email to that address")

            # TODO start transaction
            if api.actor_lookup_email(api.ROOT, email):
                raise exception.ValidationError("That email address is already associated with a member.")

            actor_ref = api.user_create(api.ROOT, **params)
            actor_ref.access_level = "delete"

            api.post(actor_ref, nick=actor_ref.nick, message="Joined %s!" % (settings.SITE_NAME), icon="jaiku-new-user")

            # send off email confirmation
            api.activation_request_email(actor_ref, actor_ref.nick, email)

            # TODO end transaction

            welcome_url = util.qsa("/welcome", {"redirect_to": redirect_to})

            # NOTE: does not provide a flash message
            response = http.HttpResponseRedirect(welcome_url)
            user.set_user_cookie(response, actor_ref)
            return response
        except:
            exception.handle_exception(request)

    # for legal section
    legal_component = component.include("legal", "dummy_legal")
    legal_html = legal_component.embed_join()

    # for sidebar
    sidebar_green_top = True

    area = "join"
    c = template.RequestContext(request, locals())

    t = loader.get_template("join.html")
    return http.HttpResponse(t.render(c))
Example #5
0
 def post(self, from_jid, 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")
   entry_ref = api.post(jid_ref, nick=jid_ref.nick, message=message)