Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlueSky - Show Friendly Url on Post #254

Merged
merged 1 commit into from
Oct 13, 2023
Merged
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
20 changes: 18 additions & 2 deletions electron-app/src/server/websites/bluesky/bluesky.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ export class Bluesky extends Website {
password: accountData.password,
});

let profile = await agent.getProfile({actor: agent.session.did });

const reply = await this.getReplyRef(agent, data.options.replyToUrl);

const files = [data.primary, ...data.additional];
Expand Down Expand Up @@ -253,8 +255,14 @@ export class Bluesky extends Website {
});

if (postResult && postResult.uri) {
// Generate a friendly URL
const handle = profile.data.handle;
const server = "bsky.app"; // Can't use the agent sadly, but this might change later: agent.service.hostname;
const postId = postResult.uri.slice(postResult.uri.lastIndexOf('/') + 1);

let friendlyUrl = `https://${server}/profile/${handle}/post/${postId}`;
return this.createPostResponse({
source: postResult.uri,
source: friendlyUrl,
});
} else {
return Promise.reject(this.createPostResponse({ message: 'Unknown error occurred' }));
Expand All @@ -275,6 +283,8 @@ export class Bluesky extends Website {
password: accountData.password,
});

let profile = await agent.getProfile({actor: agent.session.did });

const reply = await this.getReplyRef(agent, data.options.replyToUrl);
const status = this.appendRichTextTags(data.tags, data.description);

Expand All @@ -301,8 +311,14 @@ export class Bluesky extends Website {
});

if (postResult && postResult.uri) {
// Generate a friendly URL
const handle = profile.data.handle;
const server = "bsky.app"; // Can't use the agent sadly, but this might change later: agent.service.hostname;
const postId = postResult.uri.slice(postResult.uri.lastIndexOf('/') + 1);

let friendlyUrl = `https://${server}/profile/${handle}/post/${postId}`;
return this.createPostResponse({
source: postResult.uri,
source: friendlyUrl,
});
} else {
return Promise.reject(this.createPostResponse({ message: 'Unknown error occurred' }));
Expand Down