From 51bfc4bd305d8e00934b5dadef2732be7b09496a Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 13 Aug 2022 22:37:44 +0200 Subject: [PATCH] Various tweaks about AP types --- app/ap_object.py | 2 +- app/lookup.py | 2 +- app/main.py | 2 ++ app/static/new.js | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/ap_object.py b/app/ap_object.py index 9f18b8b..050ef33 100644 --- a/app/ap_object.py +++ b/app/ap_object.py @@ -31,7 +31,7 @@ class Object: @cached_property def ap_type(self) -> str: - return self.ap_object["type"] + return ap.as_list(self.ap_object["type"])[0] @property def ap_object(self) -> ap.RawObject: diff --git a/app/lookup.py b/app/lookup.py index daa9ad7..a3f05d6 100644 --- a/app/lookup.py +++ b/app/lookup.py @@ -33,7 +33,7 @@ async def lookup(db_session: AsyncSession, query: str) -> Actor | RemoteObject: else: raise - if ap_obj["type"] in ap.ACTOR_TYPES: + if ap.as_list(ap_obj["type"])[0] in ap.ACTOR_TYPES: actor = await fetch_actor(db_session, ap_obj["id"]) return actor else: diff --git a/app/main.py b/app/main.py index fc28f78..7c91578 100644 --- a/app/main.py +++ b/app/main.py @@ -76,6 +76,7 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac # TODO(ts): # # Next: +# - allow to share old notes # - allow to interact with object not in anybox (i.e. like from a lookup) # - only show 10 most recent threads in DMs # - custom CSS for disabled button (e.g. sharing on a direct post) @@ -469,6 +470,7 @@ async def outbox( .where( models.OutboxObject.visibility == ap.VisibilityEnum.PUBLIC, models.OutboxObject.is_deleted.is_(False), + models.OutboxObject.ap_type.in_(["Create", "Announce"]), ) .order_by(models.OutboxObject.ap_published_at.desc()) .limit(20) diff --git a/app/static/new.js b/app/static/new.js index 87b02bb..065bad5 100644 --- a/app/static/new.js +++ b/app/static/new.js @@ -50,3 +50,7 @@ files.addEventListener("change", function(e) { alts.appendChild(p); } }); +// Focus at the end of the textarea +const end = ta.value.length; +ta.setSelectionRange(end, end); +ta.focus();