social media crossposting tool. 3rd time's the charm
mastodon misskey crossposting bluesky

add self-quotes to misskey and mastodon inputs

zenfyr.dev bcd918f5 1bf4ab28

verified
Changed files
+17 -7
cross
mastodon
misskey
+1
cross/attachments.py
···
@dataclass(kw_only=True)
class QuoteAttachment(Attachment):
quoted_id: str
+
quoted_user: str
+8 -3
mastodon/input.py
···
LabelsAttachment,
LanguagesAttachment,
MediaAttachment,
+
QuoteAttachment,
RemoteUrlAttachment,
SensitiveAttachment,
)
···
self.log.info("Skipping '%s'! Contains a poll..", status["id"])
return
-
if status.get("quote"):
-
self.log.info("Skipping '%s'! Quote..", status["id"])
-
return
+
quote: dict[str, Any] | None = status.get("quote")
+
if quote:
+
quote = quote['quoted_status'] if quote.get('quoted_status') else quote
+
if not quote or quote["account"]["id"] != self.user_id:
+
return
in_reply: str | None = status.get("in_reply_to_id")
in_reply_to: str | None = status.get("in_reply_to_account_id")
···
post = Post(id=status["id"], parent_id=in_reply, text=text)
post.fragments.extend(fragments)
+
if quote:
+
post.attachments.put(QuoteAttachment(quoted_id=quote['id'], quoted_user=self.user_id))
if status.get("url"):
post.attachments.put(RemoteUrlAttachment(url=status["url"]))
if status.get("sensitive"):
+8 -4
misskey/input.py
···
from cross.attachments import (
LabelsAttachment,
MediaAttachment,
+
QuoteAttachment,
RemoteUrlAttachment,
SensitiveAttachment,
)
···
renote: dict[str, Any] | None = note.get("renote")
if renote:
-
if note.get("text") is not None:
-
self.log.info("Skipping '%s'! Quote..", note["id"])
+
if note.get("text") is None:
+
self._on_renote(note, renote)
+
return
+
+
if renote["userId"] != self.user_id:
return
-
self._on_renote(note, renote)
-
return
reply: dict[str, Any] | None = note.get("reply")
if reply:
···
post.fragments.extend(fragments)
post.attachments.put(RemoteUrlAttachment(url=self.url + "/notes/" + note["id"]))
+
if renote:
+
post.attachments.put(QuoteAttachment(quoted_id=renote['id'], quoted_user=self.user_id))
if any([a.get("isSensitive", False) for a in note.get("files", [])]):
post.attachments.put(SensitiveAttachment(sensitive=True))
if note.get("cw"):