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 @@ -14,8 +14,13 @@ class Bloom:
content: str
sent_timestamp: datetime.datetime

MAX_BLOOM_LENGTH = 280 # this is to ensure the extra safety

def add_bloom(*, sender: User, content: str) -> Bloom:

if len(content) > MAX_BLOOM_LENGTH:
raise ValueError(f"blooms content is too long(max {MAX_BLOOM_LENGTH})")

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

now = datetime.datetime.now(tz=datetime.UTC)
Expand Down
11 changes: 10 additions & 1 deletion backend/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,22 @@ def do_follow():
}
)


MAX_BLOOM_LENGTH = 280
@jwt_required()
def send_bloom():
type_check_error = verify_request_fields({"content": str})
if type_check_error is not None:
return type_check_error

content = request.json ["content"]

if len(content) > MAX_BLOOM_LENGTH:
return make_response(
({"success": False,
"message": f"blloms can't be longe than {MAX_BLOOM_LENGTH} symbols",
}, 400,)
)

user = get_current_user()

blooms.add_bloom(sender=user, content=request.json["content"])
Expand Down
4 changes: 2 additions & 2 deletions front-end/views/profile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function profileView(username) {
createLogin
);
document
.querySelector("[data-action='login']")
?.addEventListener("click", handleLogin);
.querySelector("[data-form='login']")
?.addEventListener("submit", handleLogin);

const profileData = state.profiles.find((p) => p.username === username);
if (profileData) {
Expand Down