Mercurial > libervia-web
diff libervia.tac @ 61:80c490e6a1a7
server side: misc stuff:
- using twisted.web.resource.NoResource instead of deprecated twisted.web.error.NoResource
- session's jid was badly saved, fixed
- fixed bad account domain and bad administrator mail when sending mails
- added a specialy return value for session already active
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 31 May 2011 17:03:37 +0200 |
parents | d0fa4e96a5e4 |
children | 9d8e79ac4c9c |
line wrap: on
line diff
--- a/libervia.tac Mon May 30 16:13:07 2011 +0200 +++ b/libervia.tac Tue May 31 17:03:37 2011 +0200 @@ -35,8 +35,7 @@ from twisted.web import server from twisted.web import error as weberror from twisted.web.static import File -from twisted.web.resource import Resource -from twisted.web.error import NoResource +from twisted.web.resource import Resource, NoResource from twisted.python.components import registerAdapter from twisted.words.protocols.jabber.jid import JID from txjsonrpc.web import jsonrpc @@ -141,8 +140,8 @@ """Return the jid of the profile""" sat_session = ISATSession(self.session) profile = sat_session.profile - sat_session.sat_jid = JID(self.sat_host.bridge.getParamA("JabberID", "Connection", profile_key=profile)) - return sat_session.sat_jid.full() + sat_session.jid = JID(self.sat_host.bridge.getParamA("JabberID", "Connection", profile_key=profile)) + return sat_session.jid.full() def jsonrpc_getContacts(self): """Return all passed args.""" @@ -181,7 +180,6 @@ def jsonrpc_setStatus(self, status): """Change the status""" profile = ISATSession(self.session).profile - print "new status received:", status self.sat_host.bridge.setPresence('', '', 0, {'':status}, profile) @@ -199,7 +197,6 @@ text = match.group(2) if recip == '@' and text: #This text if for the public microblog - print "Sending message to everybody" return self.sat_host.bridge.sendPersonalEvent("MICROBLOG", {'content':text}, profile) else: return self.sat_host.bridge.sendGroupBlog([recip], text, profile) @@ -385,7 +382,7 @@ self.sat_host.bridge.setParam("Server", _NEW_ACCOUNT_SERVER, "Connection", profile) self.sat_host.bridge.setParam("Password", password, "Connection", profile) #and the account - action_id = self.sat_host.bridge.registerNewAccount(login, password, email, "tazar.int", 5222) + action_id = self.sat_host.bridge.registerNewAccount(login, password, email, _NEW_ACCOUNT_DOMAIN, 5222) self.sat_host.action_handler.waitForId(action_id, self._postAccountCreation, profile) #time to send the email @@ -430,7 +427,7 @@ msg['From'] = _email_from msg['To'] = _REG_ADMIN_EMAIL - d = sendmail(_email_host, _email_from, email, msg.as_string()) + d = sendmail(_email_host, _email_from, _REG_ADMIN_EMAIL, msg.as_string()) d.addCallbacks(email_ok, email_ko) return "REGISTRATION" @@ -444,11 +441,19 @@ def _logged(self, profile, request, finish=True): """Set everything when a user just logged and return "LOGGED" to the requester""" + def result(answer): + if finish: + request.write(answer) + request.finish() + else: + return answer + self.__cleanWaiting(profile) _session = request.getSession() sat_session = ISATSession(_session) if sat_session.profile: - error (_('/!\\ Session has already a profile, this should NEVER happen !')) + error (('/!\\ Session has already a profile, this should NEVER happen !')) + return result('SESSION_ACTIVE') sat_session.profile = profile self.sat_host.prof_connected.add(profile) @@ -466,12 +471,7 @@ d = defer.Deferred() self.sat_host.bridge.getMblogNodes(profile, d.callback, d.errback) d.addCallback(self._fillMblogNodes, _session) - - if finish: - request.write('LOGGED') - request.finish() - else: - return "LOGGED" + return result('LOGGED') def _logginError(self, login, request, error_type): """Something went wrong during loggin, return an error"""