Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion components/bluesky/actions/create-post/create-post.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "bluesky-create-post",
name: "Create Post",
description: "Creates a new post on Bluesky. [See the documentation](https://docs.bsky.app/docs/api/com-atproto-repo-create-record).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand All @@ -15,6 +15,40 @@ export default {
description: "The text content of the post.",
},
},
methods: {
parseUrls(text) {
const spans = [];
const urlRegex = /(?:[$|\W])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*[-a-zA-Z0-9@%_+~#//=])?)/g;

let match;
while ((match = urlRegex.exec(text)) !== null) {
spans.push({
start: match.index + 1,
end: urlRegex.lastIndex,
url: match[1],
});
}
return spans;
},
parseFacets(text) {
const facets = [];
for (const link of this.parseUrls(text)) {
facets.push({
index: {
byteStart: link["start"],
byteEnd: link["end"],
},
features: [
{
["$type"]: "app.bsky.richtext.facet#link",
uri: link["url"],
},
],
});
}
return facets;
},
},
async run({ $ }) {
const {
app,
Expand All @@ -28,6 +62,7 @@ export default {
record: {
["$type"]: constants.RESOURCE_TYPE.POST,
text,
facets: this.parseFacets(text),
createdAt: new Date().toISOString(),
},
},
Expand Down
2 changes: 1 addition & 1 deletion components/bluesky/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/bluesky",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream Bluesky Components",
"main": "bluesky.app.mjs",
"keywords": [
Expand Down
Loading