summaryrefslogtreecommitdiff
path: root/sw/users.py
diff options
context:
space:
mode:
Diffstat (limited to 'sw/users.py')
-rw-r--r--sw/users.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/sw/users.py b/sw/users.py
index 08302b3..71258c1 100644
--- a/sw/users.py
+++ b/sw/users.py
@@ -1,4 +1,4 @@
-from flask import Blueprint, jsonify, url_for, request, abort
+from flask import Blueprint, jsonify, url_for, request, abort, g, Response
import json
@@ -45,8 +45,10 @@ def get_user_inbox(username):
"select inbox_size from users where username=?", (username,)
).fetchone()[0]
- if inbox_size is None:
- abort(404, "User not found")
+ # since a logged-in user is required to access this endpoint, there
+ # is no way that a non-existant user can be queried (in other
+ # words, the user will not have the clearance to see an unreal
+ # user's inbox)
return jsonify(
{
@@ -139,12 +141,12 @@ def post_user_inbox_item(username):
db = get_db()
time = now()
- res = db.exec(
- "insert into inbox (recipient, received, content) values (?,?,?) ;",
- (username, time, data),
+ res = db.execute(
+ "insert into inbox (recipient, received, ap_content) values (?,?,?) ;",
+ (username, time, str(data)),
)
- db.exec(
+ db.execute(
"update users set inbox_size = inbox_size + 1 where id = ? ;", (g.user["id"],),
)
@@ -235,7 +237,7 @@ def post_user_outbox_item(username):
item_id = None
if "id" not in data:
res = db.exec(
- "insert into items (created, updated, content) "
+ "insert into items (created, updated, ap_content) "
"output Inserted.id "
"values (?,?,?) "
";",
@@ -254,7 +256,7 @@ def post_user_outbox_item(username):
if not is_ap_activity(data):
activity = create_wrapper(item_id)
res = db.exec(
- "insert into items (created, updated, content) "
+ "insert into items (created, updated, ap_content) "
"output Inserted.id "
"values (?,?,?) "
";",