def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") node_name = ht.get_required(query, "node_name") group_id = ht.get_required(query, "group_id") key_use = ht.get_required(query, "key_use") public_key_hash = ht.get_required(query, "public_key_hash") passphrase = ht.get_optional(query, "passphrase") conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_group_key(c, user_id, session_id, node_name, group_id, key_use, public_key_hash, passphrase) raise ht.ok_json({"status": "ok", "resp": resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) action = ht.get_required(query, 'action') conn = db.connect(config.db_path) try: res = None if action == 'database': c = db.cursor(conn) res = db.read_database(c) elif action == 'integrity': all_local = ht.convert_bool(ht.get_required(query, 'all_local'), 'all_local') c1 = db.cursor(conn) c2 = db.cursor(conn) res = db.check_integrity(c1, c2, all_local) else: raise ht.BadFieldResponse('action', action) raise ht.ok_json({'status' : 'ok', 'res' : res}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time') end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time') max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records') order = ht.get_optional(query, 'order') read_signature = ht.get_optional(query, 'read_signature') proof_of_work = ht.get_optional(query, 'proof_of_work') conn = db.connect(config.db_path) try: c = db.cursor(conn) post_list = db.read_post_list( c, timestamp, node_name, group_id, owner_id, start_time, end_time, max_records, order, read_signature, proof_of_work) raise ht.ok_json({'status' : 'ok', 'post_list' : post_list}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') use = ht.get_required(query, 'use') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_group_access(c, user_id, session_id, node_name, group_id, owner_id, use, passphrase) db.commit(conn) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp") node_name = ht.get_required(query, "node_name") to_user = ht.get_required(query, "to_user") from_user = ht.get_optional(query, "from_user") from_user_key_hash = ht.get_optional(query, "from_user_key_hash") from_user_key_sig = ht.get_optional(query, "from_user_key_sig") conn = db.connect(config.db_path) try: c = db.cursor(conn) max_message_size = db.read_max_message_size( c, timestamp, node_name, to_user, from_user, from_user_key_hash, from_user_key_sig ) raise ht.ok_json({"status": "ok", "max_message_size": max_message_size}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time') end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time') max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records') order = ht.get_optional(query, 'order') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_post_list(c, user_id, session_id, node_name, group_id, owner_id, start_time, end_time, max_records, order, passphrase) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') message_id = ht.get_required(query, 'message_id') public_key_hash = ht.get_required(query, 'public_key_hash') passphrase = ht.get_optional(query, 'passphrase') to_key_passphrase = ht.get_optional(query, 'to_key_passphrase') decrypt_message = ht.convert_bool(ht.get_optional(query, 'decrypt_message'), 'decrypt_message') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, validation = db.read_message(c, user_id, session_id, node_name, message_id, public_key_hash, passphrase, to_key_passphrase, decrypt_message) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'validation' : validation}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') to_user = ht.get_required(query, 'to_user') from_user_key_hash = ht.get_required(query, 'from_user_key_hash') passphrase = ht.get_optional(query, 'passphrase') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_max_message_size(c, user_id, session_id, node_name, to_user, from_user_key_hash, passphrase) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, "user_id") session_id = ht.get_required_cookie(cookies, "session_id") group_id = ht.get_required(query, "group_id") owner_id = ht.get_required(query, "owner_id") node_name = ht.get_required(query, "node_name") key_use = ht.get_required(query, "key_use") conn = db.connect(config.db_path) try: c = db.cursor(conn) key = db.read_local_group_key(c, user_id, session_id, group_id, owner_id, node_name, key_use) raise ht.ok_json({"status": "ok", "key": key}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') post_id = ht.get_required(query, 'post_id') passphrase = ht.get_optional(query, 'passphrase') decrypt_post = ht.convert_bool(ht.get_optional(query, 'decrypt_post'), 'decrypt_post') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp, validation = db.read_post(c, user_id, session_id, node_name, group_id, owner_id, post_id, passphrase, decrypt_post) raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'validation' : validation}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') user_id = ht.get_required(query, 'user_id') to_user_key = ht.get_optional(query, 'to_user_key') from_user = ht.get_optional(query, 'from_user') from_user_key = ht.get_optional(query, 'from_user_key') start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time') end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time') max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records') order = ht.get_optional(query, 'order') public_key_hash = ht.get_required(query, 'public_key_hash') signature = ht.get_required(query, 'signature') conn = db.connect(config.db_path) try: c = db.cursor(conn) message_list = db.read_message_list(c, timestamp, node_name, user_id, to_user_key, from_user, from_user_key, start_time, end_time, max_records, order, public_key_hash, signature) raise ht.ok_json({'status' : 'ok', 'message_list' : message_list}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) node_name = ht.get_required(query, 'node_name') user_class = ht.get_optional(query, 'user_class') quota_available = db.get_quota_available(node_name, user_class) raise ht.ok_json( {'status' : 'ok', 'quota_available' : quota_available})
def get_handler(environ): query = ht.parse_get_request(environ) node_name = ht.get_required(query, 'node_name') try: version = db.read_version(node_name) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) raise ht.ok_json( {'status' : 'ok', 'version' : version})
def get_handler(environ): query = ht.parse_get_request(environ) node_name = ht.get_required(query, 'node_name') user_id = ht.get_required(query, 'user_id') conn = db.connect(config.db_path) try: c = db.cursor(conn) user_exists = db.query_user(c, node_name, user_id) raise ht.ok_json({'status' : 'ok', 'user_exists' : user_exists}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') conn = db.connect(config.db_path) try: c = db.cursor(conn) params = db.get_password() raise ht.ok_json({'status' : 'ok', 'params' : params}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') public_key_hash = ht.get_required(query, 'public_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) key = db.read_public_key(c, user_id, session_id, public_key_hash) raise ht.ok_json({'status' : 'ok', 'key' : key}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) action = ht.get_required(query, 'action') conn = db.connect(config.db_path) try: c = db.cursor(conn) if action == 'database': database = db.dump_local_database(c) raise ht.ok_json({'status' : 'ok', 'database' : database}) else: raise ht.BadFieldResponse('action', action) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') user_id = ht.get_required(query, 'user_id') public_key_hash = ht.get_required(query, 'public_key_hash') signature = ht.get_required(query, 'signature') conn = db.connect(config.db_path) try: c = db.cursor(conn) quota_obj = db.read_user_quota(c, timestamp, node_name, user_id, public_key_hash, signature) raise ht.ok_json({'status' : 'ok', 'user_quota' : quota_obj}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') node_name = ht.get_required(query, 'node_name') conn = db.connect(config.db_path) try: c = db.cursor(conn) resp = db.read_version(c, user_id, session_id, node_name) raise ht.ok_json({'status' : 'ok', 'resp' : resp}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') post_signature = ht.get_required(query, 'post_signature') conn = db.connect(config.db_path) try: c = db.cursor(conn) max_post_size = db.read_max_post_size(c, timestamp, node_name, group_id, owner_id, post_signature) raise ht.ok_json({'status' : 'ok', 'max_post_size' : max_post_size}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') use = ht.get_required(query, 'use') signature = ht.get_optional(query, 'signature') conn = db.connect(config.db_path) try: c = db.cursor(conn) access = db.read_group_access(c, timestamp, node_name, group_id, owner_id, use, signature) raise ht.ok_json({'status' : 'ok', 'access' : access}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') group_id = ht.get_required(query, 'group_id') owner_id = ht.get_required(query, 'owner_id') read_signature = ht.get_optional(query, 'read_signature') proof_of_work = ht.get_optional(query, 'proof_of_work') conn = db.connect(config.db_path) try: c = db.cursor(conn) last_post_time = db.read_last_post_time(c, timestamp, node_name, group_id, owner_id, read_signature, proof_of_work) raise ht.ok_json({'status' : 'ok', 'last_post_time' : last_post_time}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') other_user_id = ht.get_optional(query, 'other_user_id') node_name = ht.get_optional(query, 'node_name') conn = db.connect(config.db_path) try: c = db.cursor(conn) keys = db.list_other_user_keys(c, user_id, session_id, other_user_id, node_name) raise ht.ok_json({'status' : 'ok', 'keys' : keys}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp") node_name = ht.get_required(query, "node_name") group_id = ht.get_required(query, "group_id") owner_id = ht.get_required(query, "owner_id") read_signature = ht.get_optional(query, "read_signature") proof_of_work = ht.get_optional(query, "proof_of_work") conn = db.connect(config.db_path) try: c = db.cursor(conn) group_quota = db.read_group_quota(c, timestamp, node_name, group_id, owner_id, read_signature, proof_of_work) raise ht.ok_json({"status": "ok", "group_quota": group_quota}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp') node_name = ht.get_required(query, 'node_name') to_user = ht.get_required(query, 'to_user') from_user = ht.get_required(query, 'from_user') from_user_key_hash = ht.get_optional(query, 'from_user_key_hash') from_user_key_sig = ht.get_optional(query, 'from_user_key_sig') conn = db.connect(config.db_path) try: c = db.cursor(conn) message_access = db.query_message_access(c, timestamp, node_name, to_user, from_user, from_user_key_hash, from_user_key_sig) raise ht.ok_json({'status' : 'ok', 'message_access' : message_access}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) cookies = ht.parse_cookies(environ) user_id = ht.get_required_cookie(cookies, 'user_id') session_id = ht.get_required_cookie(cookies, 'session_id') to_user = ht.get_required(query, 'to_user') node_name = ht.get_required(query, 'node_name') from_user_key_hash = ht.get_required(query, 'from_user_key_hash') conn = db.connect(config.db_path) try: c = db.cursor(conn) access = db.read_local_message_access(c, user_id, session_id, to_user, node_name, from_user_key_hash) raise ht.ok_json({'status' : 'ok', 'access' : access}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)
def get_handler(environ): query = ht.parse_get_request(environ) timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp") node_name = ht.get_required(query, "node_name") group_id = ht.get_required(query, "group_id") owner_id = ht.get_required(query, "owner_id") key_use = ht.get_required(query, "key_use") public_key_hash = ht.get_required(query, "public_key_hash") signature = ht.get_optional(query, "signature") conn = db.connect(config.db_path) try: c = db.cursor(conn) group_key = db.read_group_key(c, timestamp, node_name, group_id, owner_id, key_use, public_key_hash, signature) raise ht.ok_json({"status": "ok", "group_key": group_key}) except ex.SqueakException as e: raise ht.convert_squeak_exception(e) finally: db.close(conn)