feat(bluesky): add create post action

This commit is contained in:
Rıdvan Akca
2024-05-24 12:08:11 +02:00
parent 3c44f55f19
commit c07a02ef31
8 changed files with 142 additions and 1 deletions

View File

@@ -20,6 +20,7 @@
"db:migrate": "node ./bin/database/convert-migrations.js && knex migrate:latest"
},
"dependencies": {
"@atproto/api": "^0.12.13",
"@bull-board/express": "^3.10.1",
"@casl/ability": "^6.5.0",
"@graphql-tools/graphql-file-loader": "^7.3.4",

View File

@@ -0,0 +1,41 @@
import { BskyAgent, RichText } from '@atproto/api';
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create post',
key: 'createPost',
description: 'Creates a new post.',
arguments: [
{
label: 'Text',
key: 'text',
type: 'string',
required: true,
variables: true,
description: '',
},
],
async run($) {
const text = $.step.parameters.text;
const agent = new BskyAgent({ service: 'https://bsky.social/xrpc' });
const richText = new RichText({ text });
await richText.detectFacets(agent);
const body = {
repo: $.auth.data.did,
collection: 'app.bsky.feed.post',
record: {
$type: 'app.bsky.feed.post',
text: richText.text,
facets: richText.facets,
createdAt: new Date().toISOString(),
},
};
const { data } = await $.http.post('/com.atproto.repo.createRecord', body);
$.setActionItem({ raw: data });
},
});

View File

@@ -0,0 +1,3 @@
import createPost from './create-post/index.js';
export default [createPost];

View File

@@ -1,6 +1,7 @@
import defineApp from '../../helpers/define-app.js';
import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import actions from './actions/index.js';
export default defineApp({
name: 'Bluesky',
@@ -13,4 +14,5 @@ export default defineApp({
primaryColor: '1185fd',
beforeRequest: [addAuthHeader],
auth,
actions,
});

View File

@@ -54,7 +54,10 @@ export default defineConfig({
text: 'Bluesky',
collapsible: true,
collapsed: true,
items: [{ text: 'Connection', link: '/apps/bluesky/connection' }],
items: [
{ text: 'Actions', link: '/apps/bluesky/actions' },
{ text: 'Connection', link: '/apps/bluesky/connection' },
],
},
{
text: 'Carbone',

View File

@@ -0,0 +1,12 @@
---
favicon: /favicons/bluesky.svg
items:
- name: Create post
desc: Creates a new post.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -4,6 +4,7 @@ The following integrations are currently supported by Automatisch.
- [Airtable](/apps/airtable/actions)
- [Appwrite](/apps/appwrite/triggers)
- [Bluesky](/apps/bluesky/actions)
- [Carbone](/apps/carbone/actions)
- [Datastore](/apps/datastore/actions)
- [DeepL](/apps/deepl/actions)