This commit is contained in:
Madeline
2023-08-14 13:51:11 +10:00
parent c560d58f68
commit a4db643bea
9 changed files with 93 additions and 89 deletions
+22
View File
@@ -16,6 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { APActor } from "activitypub-types";
import { HTTPError } from "lambert-server";
import {
Column,
@@ -28,6 +29,7 @@ import {
import { DmChannelDTO } from "../dtos";
import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces";
import {
Config,
InvisibleCharacters,
Snowflake,
containsAll,
@@ -482,6 +484,26 @@ export class Channel extends BaseClass {
owner_id: this.owner_id || undefined,
};
}
toAP(): APActor {
const { webDomain } = Config.get().federation;
return {
"@context": "https://www.w3.org/ns/activitystreams",
type: "Group",
id: `https://${webDomain}/fed/channel/${this.id}`,
name: this.name,
preferredUsername: this.name,
summary: this.topic,
icon: undefined,
inbox: `https://${webDomain}/fed/channel/${this.id}/inbox`,
outbox: `https://${webDomain}/fed/channel/${this.id}/outbox`,
followers: `https://${webDomain}/fed/channel/${this.id}/followers`,
following: `https://${webDomain}/fed/channel/${this.id}/following`,
liked: `https://${webDomain}/fed/channel/${this.id}/likeds`,
};
}
}
export interface ChannelPermissionOverwrite {
+26 -10
View File
@@ -16,12 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { User } from "./User";
import { Member } from "./Member";
import { Role } from "./Role";
import { Channel } from "./Channel";
import { InteractionType } from "../interfaces/Interaction";
import { Application } from "./Application";
import type { APNote } from "activitypub-types";
import {
Column,
CreateDateColumn,
@@ -34,11 +29,18 @@ import {
OneToMany,
RelationId,
} from "typeorm";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
import { Webhook } from "./Webhook";
import { Sticker } from "./Sticker";
import { Config } from "..";
import { InteractionType } from "../interfaces/Interaction";
import { Application } from "./Application";
import { Attachment } from "./Attachment";
import { BaseClass } from "./BaseClass";
import { Channel } from "./Channel";
import { Guild } from "./Guild";
import { Member } from "./Member";
import { Role } from "./Role";
import { Sticker } from "./Sticker";
import { User } from "./User";
import { Webhook } from "./Webhook";
export enum MessageType {
DEFAULT = 0,
@@ -240,6 +242,20 @@ export class Message extends BaseClass {
components: this.components ?? undefined,
};
}
toAP(): APNote {
const { webDomain } = Config.get().federation;
return {
id: `https://${webDomain}/fed/channel/${this.channel_id}/messages/${this.id}`,
type: "Note",
published: this.timestamp,
url: `https://${webDomain}/fed/channel/${this.channel_id}/messages/${this.id}`,
attributedTo: `https://${webDomain}/fed/user/${this.author_id}`,
to: `https://${webDomain}/fed/channel/${this.channel_id}`,
content: this.content,
};
}
}
export interface MessageComponent {