tangled
alpha
login
or
join now
zenfyr.dev
/
xpost
2
fork
atom
social media crossposting tool. 3rd time's the charm
mastodon
misskey
crossposting
bluesky
2
fork
atom
overview
issues
1
pulls
pipelines
verify quotes actually hit the db
zenfyr.dev
5 months ago
9f45c8ac
5f5b5f17
verified
This commit was signed with the committer's
known signature
.
zenfyr.dev
SSH Key Fingerprint:
SHA256:TtcIcnTnoAB5mqHofsaOxIgiMzfVBxej1AXT7DQdrTE=
+28
-7
3 changed files
expand all
collapse all
unified
split
bluesky
input.py
mastodon
input.py
misskey
input.py
+14
-7
bluesky/input.py
reviewed
···
84
84
85
85
embed: dict[str, Any] = record.get("embed", {})
86
86
blob_urls: list[tuple[str, str, str | None]] = []
87
87
-
def handle_embeds(embed: dict[str, Any]):
87
87
+
def handle_embeds(embed: dict[str, Any]) -> str | None:
88
88
nonlocal blob_urls, post
89
89
match cast(str, embed["$type"]):
90
90
case "app.bsky.embed.record" | "app.bsky.embed.recordWithMedia":
91
91
rcrd = embed['record']['record'] if embed['record'].get('record') else embed['record']
92
92
did, collection, _ = AtUri.record_uri(rcrd["uri"])
93
93
if collection != "app.bsky.feed.post":
94
94
-
return
94
94
+
return f"Unhandled record collection {collection}"
95
95
if did != self.did:
96
96
-
return
96
96
+
return ""
97
97
+
98
98
+
rquote = self._get_post(self.url, did, rcrd["uri"])
99
99
+
if not rquote:
100
100
+
return f"Quote {rcrd["uri"]} not found in the db"
97
101
post.attachments.put(QuoteAttachment(quoted_id=rcrd["uri"], quoted_user=did))
98
102
99
103
if embed.get('media'):
100
100
-
handle_embeds(embed["media"])
104
104
+
return handle_embeds(embed["media"])
101
105
case "app.bsky.embed.images":
102
106
for image in embed["images"]:
103
107
blob_cid = image["image"]["ref"]["$link"]
···
108
112
url = f"{self.pds}/xrpc/com.atproto.sync.getBlob?did={self.did}&cid={blob_cid}"
109
113
blob_urls.append((url, blob_cid, embed.get("alt")))
110
114
case _:
111
111
-
self.log.warning(f"Unhandled embedd type {embed['$type']}")
112
112
-
pass
115
115
+
self.log.warning(f"Unhandled embed type {embed['$type']}")
116
116
+
113
117
if embed:
114
114
-
handle_embeds(embed)
118
118
+
fexit = handle_embeds(embed)
119
119
+
if fexit is not None:
120
120
+
self.log.info("Skipping %s! %s", post_uri, fexit)
121
121
+
return
115
122
116
123
if blob_urls:
117
124
blobs: list[Blob] = []
+7
mastodon/input.py
reviewed
···
89
89
if not quote or quote["account"]["id"] != self.user_id:
90
90
return
91
91
92
92
+
rquote = self._get_post(self.url, self.user_id, quote['id'])
93
93
+
if not rquote:
94
94
+
self.log.info(
95
95
+
"Skipping %s, parent %s not found in db", status["id"], quote['id']
96
96
+
)
97
97
+
return
98
98
+
92
99
in_reply: str | None = status.get("in_reply_to_id")
93
100
in_reply_to: str | None = status.get("in_reply_to_account_id")
94
101
if in_reply_to and in_reply_to != self.user_id:
+7
misskey/input.py
reviewed
···
82
82
if renote["userId"] != self.user_id:
83
83
return
84
84
85
85
+
rrenote = self._get_post(self.url, self.user_id, renote["id"])
86
86
+
if not rrenote:
87
87
+
self.log.info(
88
88
+
"Skipping %s, quote %s not found in db", note["id"], renote["id"]
89
89
+
)
90
90
+
return
91
91
+
85
92
reply: dict[str, Any] | None = note.get("reply")
86
93
if reply:
87
94
if reply.get("userId") != self.user_id: