aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-03-03 17:03:16 -0600
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-03-03 17:03:16 -0600
commit53961bbece1f4d24674ba2fc706c8525243df624 (patch)
treeabdba1b3d332e8a04c22839a62956dc295dc6124 /src
parente892d20e18a5a7002071f7ec0468437227e508a7 (diff)
downloadbbj-53961bbece1f4d24674ba2fc706c8525243df624.tar.gz
(slightly) less primitive message editing support
Diffstat (limited to 'src')
-rw-r--r--src/db.py13
-rw-r--r--src/endpoints.py15
2 files changed, 21 insertions, 7 deletions
diff --git a/src/db.py b/src/db.py
index 0eb38d7..0cbaf5a 100644
--- a/src/db.py
+++ b/src/db.py
@@ -190,7 +190,12 @@ def user_namecheck(name):
return False, schema.error(4,
"Username cannot contain whitespace chars besides spaces.")
- elif len(username) > 24:
+ elif not name.strip():
+ return False, schema.error(4,
+ "Username must contain at least one non-space character")
+
+
+ elif len(name) > 24:
return False, schema.error(4,
"Username is too long (max 24 chars)")
@@ -199,7 +204,7 @@ def user_namecheck(name):
def user_authcheck(auth_hash):
if not auth_hash:
- return schema.error(3,
+ return False, schema.error(3,
"auth_hash may not be empty")
elif len(auth_hash) != 64:
@@ -211,7 +216,7 @@ def user_authcheck(auth_hash):
def user_quipcheck(quip):
if not quip:
- return ""
+ return True, True
elif contains_nonspaces(quip):
return False, schema.error(4,
@@ -226,7 +231,7 @@ def user_quipcheck(quip):
def user_biocheck(bio):
if not bio:
- return ""
+ return True, True
elif len(bio) > 4096:
return False, schema.error(4,
diff --git a/src/endpoints.py b/src/endpoints.py
index 434f791..35a38dc 100644
--- a/src/endpoints.py
+++ b/src/endpoints.py
@@ -13,6 +13,7 @@ endpoints = {
"thread_create": ["title", "body", "tags"],
"thread_reply": ["thread_id", "body"],
"edit_post": ["thread_id", "post_id", "body"],
+ "edit_query": ["thread_id", "post_id"],
"can_edit": ["thread_id", "post_id"],
"user_register": ["user", "auth_hash", "quip", "bio"],
"user_get": ["target_user"],
@@ -100,13 +101,17 @@ def user_register(json):
return schema.response(
db.user_register(
- json["user"],
json["auth_hash"],
+ json["user"],
json["quip"],
json["bio"]))
def user_get(json):
+ """
+ On success, returns an external user object for target_user (ID or name).
+ If the user isn't in the system, returns false.
+ """
user = db.user_resolve(json["target_user"])
if not user:
return False
@@ -146,6 +151,10 @@ def thread_reply(json):
return schema.response(reply)
+def edit_query(json):
+ return db.edit_handler(json)[1]
+
+
def can_edit(json):
return db.edit_handler(json)[0]
@@ -154,9 +163,9 @@ def edit_post(json):
thread = db.thread_load(json["thread_id"])
admin = db.user_is_admin(json["user"])
target_id = json["post_id"]
- query, obj = db.edit_handler(json, thread)
+ ok, obj = db.edit_handler(json, thread)
- if query:
+ if ok:
obj["body"] = json["body"]
obj["lastmod"] = time()
obj["edited"] = True
Un proyecto texto-plano.xyz