Exemple #1
0
    def post(self, token):
        obj = lib.lookup_token(token, self.current_user)
        if not obj:
            raise tornado.web.HTTPError(404)
        if self.get_argument('action.update_alias', None):
            alias = self.get_argument('alias')
            if obj.alias != alias and alias:
                obj.alias = alias
                obj.put()
                lib.send(obj, '/alias %s' % alias)

        elif self.get_argument('action.partychat_migration', None):
            obj.jid = obj.jid.replace('at.partych.at', 'im.partych.at')
            obj.put()
        
        elif self.get_argument('action.new_post_hook', None):
            t = model.PostHook(
                token=lib.get_new_token('post'),
                jid=obj
            )
            t.put()
        elif self.get_argument('action.update_post_hook', None):
            hook_token = self.get_argument('token')
            if hook_token.lower().startswith('p_'):
                t = lib.lookup_token(hook_token, self.current_user)
                if t:
                    t.format = self.get_argument('format')
                    t.put()
        elif self.get_argument('action.new_receive_hook', None):
            t = model.ReceiveHook(
                token=lib.get_new_token('receive'),
                jid=obj)
            t.put()
        elif self.get_argument('action.update_receive_hook', None):
            hook_token = self.get_argument('token')
            if hook_token.lower().startswith('r_'):
                t = lib.lookup_token(hook_token, self.current_user)
                if t:
                    t.endpoint = self.get_argument('endpoint')
                    t.command = self.get_argument('command') or '*'
                    t.put()
        elif self.get_argument('action.activate', None):
            hook_token = self.get_argument('action.activate')
            t = lib.lookup_token(hook_token, self.current_user)
            if t:
                t.active = True
                t.put()
        elif self.get_argument('action.deactivate', None):
            hook_token = self.get_argument('action.deactivate')
            t = lib.lookup_token(hook_token, self.current_user)
            if t:
                t.active = False
                t.put()
        self.redirect('/edit/' + obj.token)
Exemple #2
0
 def post(self):
     jid = self.get_argument('jid')
     token = lib.get_new_token('jid')
     obj = model.JID(jid=jid,
         user=self.current_user,
         token=token)
     obj.put()
     self.redirect('/edit/' + token)