diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts
index a5191dc3..8b692ac7 100644
--- a/src/util/entities/Channel.ts
+++ b/src/util/entities/Channel.ts
@@ -387,6 +387,18 @@ export class Channel extends BaseClass {
if (channel == null) {
name = trimSpecial(name);
+ const { publicKey, privateKey } = await generateKeyPair("rsa", {
+ modulusLength: 4096,
+ publicKeyEncoding: {
+ type: "spki",
+ format: "pem",
+ },
+ privateKeyEncoding: {
+ type: "pkcs8",
+ format: "pem",
+ },
+ });
+
channel = await Channel.create({
name,
type,
@@ -403,6 +415,8 @@ export class Channel extends BaseClass {
}),
),
nsfw: false,
+ publicKey,
+ privateKey,
}).save();
}
diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts
index bbbb2ac1..3bf3b9d0 100644
--- a/src/util/entities/Message.ts
+++ b/src/util/entities/Message.ts
@@ -16,7 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import type { APAnnounce, APNote } from "activitypub-types";
+import type { APAnnounce, APCreate, APNote } from "activitypub-types";
import {
Column,
CreateDateColumn,
@@ -220,6 +220,9 @@ export class Message extends BaseClass {
@Column({ type: "simple-json", nullable: true })
components?: MessageComponent[];
+ @Column({ nullable: true })
+ federatedId: string;
+
toJSON(): Message {
return {
...this,
@@ -227,6 +230,7 @@ export class Message extends BaseClass {
member_id: undefined,
webhook_id: undefined,
application_id: undefined,
+ federatedId: undefined,
nonce: this.nonce ?? undefined,
tts: this.tts ?? false,
@@ -256,6 +260,19 @@ export class Message extends BaseClass {
};
}
+ toCreateAP(): APCreate {
+ const { webDomain } = Config.get().federation;
+
+ return {
+ "@context": "https://www.w3.org/ns/activitystreams",
+ type: "Create",
+ id: `https://${webDomain}/fed/channel/${this.channel_id}/messages/${this.id}`,
+ to: [],
+ actor: `https://${webDomain}/fed/user/${this.author_id}`,
+ object: this.toAP(),
+ };
+ }
+
// TODO: move to AP module
toAP(): APNote {
const { webDomain } = Config.get().federation;
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index f9213693..1594093f 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -252,6 +252,9 @@ export class User extends BaseClass {
@Column({ select: false })
privateKey: string;
+ @Column({ nullable: true })
+ federatedId: string;
+
// TODO: I don't like this method?
validate() {
if (this.discriminator) {
|