Skip to content

Commit efd0be5

Browse files
fix: Add 280 character limit to blooms
1 parent b2dcd10 commit efd0be5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

backend/endpoints.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from datetime import timedelta
1919

2020
MINIMUM_PASSWORD_LENGTH = 5
21+
MAXIMUM_BLOOM_LENGTH = 280
2122

2223

2324
def login():
@@ -156,9 +157,20 @@ def send_bloom():
156157
if type_check_error is not None:
157158
return type_check_error
158159

160+
content = request.json["content"]
161+
162+
if len(content) > MAXIMUM_BLOOM_LENGTH:
163+
return make_response(
164+
jsonify({
165+
"success": False,
166+
"message": f"Bloom content exceeds maximum length of {MAXIMUM_BLOOM_LENGTH} characters"
167+
}),
168+
400
169+
)
170+
159171
user = get_current_user()
160172

161-
blooms.add_bloom(sender=user, content=request.json["content"])
173+
blooms.add_bloom(sender=user, content=content)
162174

163175
return jsonify(
164176
{

backend/populate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def main():
6464
writer_access_token = create_user("AS", "neverSt0pTalking")
6565
send_bloom(
6666
writer_access_token,
67-
"In this essay I will convince you that my views are correct in ways you have never imagined. If it doesn't change your life, read it again. Marshmallows are magnificent. They have great squish, tasty good, and you can even toast them over a fire. Toast them just right until they have a tiny bit of crunch when you bite into them, and have just started melting in the middle.",
67+
"In this essay I will convince you that my views are correct in ways you have never imagined. If it doesn't change your life, read it again. Marshmallows are magnificent. They have great squish, tasty good, and you can toast them over a fire.",
6868
)
6969

7070
justsomeguy_access_token = create_user("JustSomeGuy", "mysterious")

0 commit comments

Comments
 (0)