예제 #1
0
 def post(self):
     if account.unauthorized_request(self):
         return
     chan = memcache.get("cha_" + account.get_cookie(self))
     if not chan:
         chan = channel.create_channel(gen_id(20))
         add_chatter(account.get_cookie(self), chan)
     self.response.write(json.dumps({"token": chan}))
예제 #2
0
 def post(self):
     if account.unauthorized_request(self):
         return
     chan = memcache.get("cha_" + account.get_cookie(self))
     if not chan:
         chan = channel.create_channel(gen_id(20))
         add_chatter(account.get_cookie(self), chan)
     self.response.write(json.dumps({"token": chan}))
예제 #3
0
 def post(self):
     if account.get_cookie(self):
         name = account.get_user(self)
         for chan in get_channels():
             channel.send_message(
                 chan, json.dumps({
                     "name": name,
                     "msg": "[disconnect]"
                 }))
예제 #4
0
def raw_email_parser(self):
    # replacer
    user = account.get_user(account.get_cookie(self))
    replace_info = {
        EMAIL_NAME: user.first_name + " " + user.last_name,
        EMAIL_GRADE: user.grade,
        EMAIL_PEOPLE: self.request.get(DATA_PEOPLE,
                                       default_value="ERR").strip(),
        EMAIL_COMPANY: self.request.get(DATA_COMPANY,
                                        default_value="ERR").strip()
    }

    status = "complete"
    for key, value in globals().items():
        if not "DATA_" in key or "_cc" in key:
            continue
        fail_value = "~*h8fnusd8*812*hjaisudnU*NU*7sdhfb*(*H"
        real_value = self.request.get(value, default_value=fail_value)
        if fail_value is not real_value and len(real_value) > 0:
            continue
        status = "incomplete"

    target = []
    cc_target = []
    if status is not "incomplete":
        target = [
            x.strip() for x in self.request.get(DATA_EMAIL_MAIN,
                                                default_value="").split(',')
        ]
        cc_target = [
            x.strip() for x in self.request.get(DATE_EMAIL_CC,
                                                default_value="").split(',')
        ]
        if not valid_emails(target):
            status = "invalid"

        if len(cc_target) > 0 and len(cc_target[0]) > 0:
            if not valid_emails(cc_target):
                status = "invalid"
        else:
            cc_target = None

    # replace
    email_info = data[self.request.get("email_type",
                                       "default").lower().strip()]
    email = email_info["data"]
    for key, value in replace_info.items():
        email = email.replace("${" + key + "}", value)

    return {
        "status": status,
        "email": email,
        "name": email_info["name"],
        "to": target,
        "cc": cc_target
    }
예제 #5
0
 def post(self):
     if account.unauthorized_request(self):
         return
     msg = self.request.get("msg")
     if not msg:
         self.error(400)
         return
     if msg in commands:
         self.error(403)
         return
     user = account.get_user(account.get_cookie(self))
     serialized_msg = json.dumps({"name": user.full_name(), "msg": msg})
     for chan in get_channels():
         channel.send_message(chan, serialized_msg)
     messages = get_messages()[:100]
     messages.insert(0, serialized_msg)
     memcache.set("msgs", messages, 24 * 60 * 5)
     self.response.write(serialized_msg)
예제 #6
0
 def post(self):
     if account.unauthorized_request(self):
         return
     msg = self.request.get("msg")
     if not msg:
         self.error(400)
         return
     if msg in commands:
         self.error(403)
         return
     user = account.get_user(account.get_cookie(self))
     serialized_msg = json.dumps({"name": user.full_name(), "msg": msg})
     for chan in get_channels():
         channel.send_message(chan, serialized_msg)
     messages = get_messages()[:100]
     messages.insert(0, serialized_msg)
     memcache.set("msgs", messages, 24 * 60 * 5)
     self.response.write(serialized_msg)
예제 #7
0
 def get(self):
     valid = account.verify(account.get_cookie(self))
     self.response.write(
         open("site/" + ("admin" if valid else "login") + ".html").read())
예제 #8
0
 def post(self):
     if account.get_cookie(self):
         name = account.get_user(self)
         for chan in get_channels():
             channel.send_message(chan, json.dumps({"name": name, "msg": "[disconnect]"}))