mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Refactor configs and activitypub parts
This commit is contained in:
parent
ca7d325cb1
commit
c0ff46559b
17 changed files with 251 additions and 70 deletions
|
|
@ -116,7 +116,7 @@ export class RawActor extends BaseEntity {
|
|||
username: preferredUsername ?? "",
|
||||
display_name: name ?? preferredUsername ?? "",
|
||||
note: summary ?? "",
|
||||
url: `${config.http.base_url}/@${preferredUsername}${
|
||||
url: `${config.http.base_url}/users/${preferredUsername}${
|
||||
isLocalUser ? "" : `@${this.getInstanceDomain()}`
|
||||
}`,
|
||||
avatar:
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ export class Status extends BaseEntity {
|
|||
}
|
||||
|
||||
newStatus.object.data = {
|
||||
id: `${config.http.base_url}/@${data.account.username}/statuses/${newStatus.id}`,
|
||||
id: `${config.http.base_url}/users/${data.account.username}/statuses/${newStatus.id}`,
|
||||
type: "Note",
|
||||
summary: data.spoiler_text,
|
||||
content: data.content, // TODO: Format as HTML
|
||||
|
|
@ -229,14 +229,14 @@ export class Status extends BaseEntity {
|
|||
: undefined,
|
||||
published: new Date().toISOString(),
|
||||
tag: [],
|
||||
attributedTo: `${config.http.base_url}/@${data.account.username}`,
|
||||
attributedTo: `${config.http.base_url}/users/${data.account.username}`,
|
||||
};
|
||||
|
||||
// Get people mentioned in the content
|
||||
const mentionedPeople = [
|
||||
...data.content.matchAll(/@([a-zA-Z0-9_]+)/g),
|
||||
].map(match => {
|
||||
return `${config.http.base_url}/@${match[1]}`;
|
||||
return `${config.http.base_url}/users/${match[1]}`;
|
||||
});
|
||||
|
||||
// Map this to Users
|
||||
|
|
@ -286,7 +286,7 @@ export class Status extends BaseEntity {
|
|||
|
||||
if (data.visibility === "private") {
|
||||
newStatus.object.data.cc = [
|
||||
`${config.http.base_url}/@${data.account.username}/followers`,
|
||||
`${config.http.base_url}/users/${data.account.username}/followers`,
|
||||
];
|
||||
} else if (data.visibility === "direct") {
|
||||
// Add nothing else
|
||||
|
|
@ -296,7 +296,7 @@ export class Status extends BaseEntity {
|
|||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
];
|
||||
newStatus.object.data.cc = [
|
||||
`${config.http.base_url}/@${data.account.username}/followers`,
|
||||
`${config.http.base_url}/users/${data.account.username}/followers`,
|
||||
];
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ export class User extends BaseEntity {
|
|||
|
||||
// Check if actor exists
|
||||
const actorExists = await RawActor.getByActorId(
|
||||
`${config.http.base_url}/@${this.username}`
|
||||
`${config.http.base_url}/users/${this.username}`
|
||||
);
|
||||
|
||||
let actor: RawActor;
|
||||
|
|
@ -395,14 +395,14 @@ export class User extends BaseEntity {
|
|||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
],
|
||||
id: `${config.http.base_url}/@${this.username}`,
|
||||
id: `${config.http.base_url}/users/${this.username}`,
|
||||
type: "Person",
|
||||
preferredUsername: this.username,
|
||||
name: this.display_name,
|
||||
inbox: `${config.http.base_url}/@${this.username}/inbox`,
|
||||
outbox: `${config.http.base_url}/@${this.username}/outbox`,
|
||||
followers: `${config.http.base_url}/@${this.username}/followers`,
|
||||
following: `${config.http.base_url}/@${this.username}/following`,
|
||||
inbox: `${config.http.base_url}/users/${this.username}/inbox`,
|
||||
outbox: `${config.http.base_url}/users/${this.username}/outbox`,
|
||||
followers: `${config.http.base_url}/users/${this.username}/followers`,
|
||||
following: `${config.http.base_url}/users/${this.username}/following`,
|
||||
manuallyApprovesFollowers: false,
|
||||
summary: this.note,
|
||||
icon: {
|
||||
|
|
@ -414,8 +414,8 @@ export class User extends BaseEntity {
|
|||
url: this.header,
|
||||
},
|
||||
publicKey: {
|
||||
id: `${config.http.base_url}/@${this.username}/actor#main-key`,
|
||||
owner: `${config.http.base_url}/@${this.username}/actor`,
|
||||
id: `${config.http.base_url}/users/${this.username}/actor#main-key`,
|
||||
owner: `${config.http.base_url}/users/${this.username}/actor`,
|
||||
publicKeyPem: this.public_key,
|
||||
},
|
||||
} as APActor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue