feat(bluesky): add search post by url action

This commit is contained in:
Rıdvan Akca
2024-05-27 15:22:23 +02:00
parent c07a02ef31
commit 84ecf105c2
3 changed files with 39 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import createPost from './create-post/index.js'; import createPost from './create-post/index.js';
import searchPostByUrl from './search-post-by-url/index.js';
export default [createPost]; export default [createPost, searchPostByUrl];

View File

@@ -0,0 +1,35 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Search post by url',
key: 'searchPostByUrl',
description: 'Searches a post in a thread by url.',
arguments: [
{
label: 'Post Url',
key: 'postUrl',
type: 'string',
required: true,
variables: true,
description: 'Enter whole post url here.',
},
],
async run($) {
const postUrl = $.step.parameters.postUrl;
const urlParts = postUrl.split('/');
const handle = urlParts[urlParts.length - 3];
const postId = urlParts[urlParts.length - 1];
const uri = `at://${handle}/app.bsky.feed.post/${postId}`;
const params = {
uri,
};
const { data } = await $.http.get('/app.bsky.feed.getPostThread', {
params,
});
$.setActionItem({ raw: data });
},
});

View File

@@ -3,6 +3,8 @@ favicon: /favicons/bluesky.svg
items: items:
- name: Create post - name: Create post
desc: Creates a new post. desc: Creates a new post.
- name: Search post by url
desc: Searches a post in a thread by url.
--- ---
<script setup> <script setup>