From c8a9793638878b5889cd589ad1ace06e8ae51dc7 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 5 Oct 2022 20:27:21 +0200 Subject: [PATCH] Make hashtag case insensitive --- app/boxes.py | 5 +++-- app/main.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index 043bf55..2ccd199 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -32,6 +32,7 @@ from app.config import MANUALLY_APPROVES_FOLLOWERS from app.config import set_moved_to from app.database import AsyncSession from app.outgoing_activities import new_outgoing_activity +from app.source import dedup_tags from app.source import markdownify from app.uploads import upload_to_attachment from app.utils import opengraph @@ -542,7 +543,7 @@ async def send_create( "context": context, "conversation": context, "url": outbox_object_id(note_id), - "tag": tags, + "tag": dedup_tags(tags), "summary": content_warning, "inReplyTo": in_reply_to, "sensitive": is_sensitive, @@ -562,7 +563,7 @@ async def send_create( for tag in tags: if tag["type"] == "Hashtag": tagged_object = models.TaggedOutboxObject( - tag=tag["name"][1:], + tag=tag["name"][1:].lower(), outbox_object_id=outbox_object.id, ) db_session.add(tagged_object) diff --git a/app/main.py b/app/main.py index 68312a1..9a1c7f2 100644 --- a/app/main.py +++ b/app/main.py @@ -763,7 +763,7 @@ async def tag_by_name( _: httpsig.HTTPSigInfo = Depends(httpsig.httpsig_checker), ) -> ActivityPubResponse | templates.TemplateResponse: where = [ - models.TaggedOutboxObject.tag == tag, + models.TaggedOutboxObject.tag == tag.lower(), models.OutboxObject.visibility == ap.VisibilityEnum.PUBLIC, models.OutboxObject.is_deleted.is_(False), ] @@ -789,7 +789,7 @@ async def tag_by_name( return ActivityPubResponse( { "@context": ap.AS_CTX, - "id": BASE_URL + f"/t/{tag}", + "id": BASE_URL + f"/t/{tag.lower()}", "type": "OrderedCollection", "totalItems": tagged_count, "orderedItems": [