Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/data/blooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class Bloom:


def add_bloom(*, sender: User, content: str) -> Bloom:
#------validation-----------
MAX_CHARACTERS = 280
if len(content) > MAX_CHARACTERS
raise ValueError(f"Bloom exceeds {MAX_CHARACTERS} characters.")

hashtags = [word[1:] for word in content.split(" ") if word.startswith("#")]

now = datetime.datetime.now(tz=datetime.UTC)
Expand Down
9 changes: 9 additions & 0 deletions backend/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ def send_bloom():
if type_check_error is not None:
return type_check_error

content = request.json["content"]

#----Validation-----
if len(content) > 280:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh! You did so well to introduce a constant in the other file. You need to use the same constant here too!

return make_response(jsonify({
"success": False,
"message" : "Bloom is too long! Max 280 characters"
}), 400)

user = get_current_user()

blooms.add_bloom(sender=user, content=request.json["content"])
Expand Down