Various tweaks about AP types

This commit is contained in:
Thomas Sileo 2022-08-13 22:37:44 +02:00
parent 1f36348021
commit 51bfc4bd30
4 changed files with 8 additions and 2 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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)

View File

@ -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();