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
+17 -7
+1
cross/attachments.py
··· 34 34 @dataclass(kw_only=True) 35 35 class QuoteAttachment(Attachment): 36 36 quoted_id: str 37 + quoted_user: str
+8 -3
mastodon/input.py
··· 10 10 LabelsAttachment, 11 11 LanguagesAttachment, 12 12 MediaAttachment, 13 + QuoteAttachment, 13 14 RemoteUrlAttachment, 14 15 SensitiveAttachment, 15 16 ) ··· 82 83 self.log.info("Skipping '%s'! Contains a poll..", status["id"]) 83 84 return 84 85 85 - if status.get("quote"): 86 - self.log.info("Skipping '%s'! Quote..", status["id"]) 87 - return 86 + quote: dict[str, Any] | None = status.get("quote") 87 + if quote: 88 + quote = quote['quoted_status'] if quote.get('quoted_status') else quote 89 + if not quote or quote["account"]["id"] != self.user_id: 90 + return 88 91 89 92 in_reply: str | None = status.get("in_reply_to_id") 90 93 in_reply_to: str | None = status.get("in_reply_to_account_id") ··· 106 109 post = Post(id=status["id"], parent_id=in_reply, text=text) 107 110 post.fragments.extend(fragments) 108 111 112 + if quote: 113 + post.attachments.put(QuoteAttachment(quoted_id=quote['id'], quoted_user=self.user_id)) 109 114 if status.get("url"): 110 115 post.attachments.put(RemoteUrlAttachment(url=status["url"])) 111 116 if status.get("sensitive"):
+8 -4
misskey/input.py
··· 10 10 from cross.attachments import ( 11 11 LabelsAttachment, 12 12 MediaAttachment, 13 + QuoteAttachment, 13 14 RemoteUrlAttachment, 14 15 SensitiveAttachment, 15 16 ) ··· 74 75 75 76 renote: dict[str, Any] | None = note.get("renote") 76 77 if renote: 77 - if note.get("text") is not None: 78 - self.log.info("Skipping '%s'! Quote..", note["id"]) 78 + if note.get("text") is None: 79 + self._on_renote(note, renote) 80 + return 81 + 82 + if renote["userId"] != self.user_id: 79 83 return 80 - self._on_renote(note, renote) 81 - return 82 84 83 85 reply: dict[str, Any] | None = note.get("reply") 84 86 if reply: ··· 101 103 post.fragments.extend(fragments) 102 104 103 105 post.attachments.put(RemoteUrlAttachment(url=self.url + "/notes/" + note["id"])) 106 + if renote: 107 + post.attachments.put(QuoteAttachment(quoted_id=renote['id'], quoted_user=self.user_id)) 104 108 if any([a.get("isSensitive", False) for a in note.get("files", [])]): 105 109 post.attachments.put(SensitiveAttachment(sensitive=True)) 106 110 if note.get("cw"):