mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
add more shit idk
This commit is contained in:
parent
1027eada7c
commit
8946d4593c
|
|
@ -14,6 +14,7 @@ import { User } from "./User";
|
||||||
import { Application } from "./Application";
|
import { Application } from "./Application";
|
||||||
import { Emoji } from "./Emoji";
|
import { Emoji } from "./Emoji";
|
||||||
import { Favourite } from "./Favourite";
|
import { Favourite } from "./Favourite";
|
||||||
|
import { RawActivity } from "./RawActivity";
|
||||||
|
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
|
|
||||||
|
|
@ -68,6 +69,12 @@ export class Status extends BaseEntity {
|
||||||
@ManyToMany(() => Emoji, emoji => emoji.id)
|
@ManyToMany(() => Emoji, emoji => emoji.id)
|
||||||
emojis!: Emoji[];
|
emojis!: Emoji[];
|
||||||
|
|
||||||
|
@ManyToMany(() => RawActivity, activity => activity.id, {})
|
||||||
|
likes: RawActivity[] = [];
|
||||||
|
|
||||||
|
@ManyToMany(() => RawActivity, activity => activity.id, {})
|
||||||
|
announces: RawActivity[] = [];
|
||||||
|
|
||||||
async getFavourites(): Promise<Favourite[]> {
|
async getFavourites(): Promise<Favourite[]> {
|
||||||
return Favourite.find({
|
return Favourite.find({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,12 @@ export class User extends BaseEntity {
|
||||||
username!: string;
|
username!: string;
|
||||||
|
|
||||||
@Column("varchar", {
|
@Column("varchar", {
|
||||||
nullable: true,
|
unique: true,
|
||||||
})
|
})
|
||||||
password!: string | null;
|
display_name!: string;
|
||||||
|
|
||||||
|
@Column("varchar")
|
||||||
|
password!: string;
|
||||||
|
|
||||||
@Column("varchar", {
|
@Column("varchar", {
|
||||||
unique: true,
|
unique: true,
|
||||||
|
|
@ -47,9 +50,6 @@ export class User extends BaseEntity {
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updated_at!: Date;
|
updated_at!: Date;
|
||||||
|
|
||||||
@Column("boolean")
|
|
||||||
isRemote!: boolean;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/require-await
|
// eslint-disable-next-line @typescript-eslint/require-await
|
||||||
async toAPI(): Promise<APIAccount> {
|
async toAPI(): Promise<APIAccount> {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
17
server/api/.well-known/nodeinfo/index.ts
Normal file
17
server/api/.well-known/nodeinfo/index.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { MatchedRoute } from "bun";
|
||||||
|
import { getHost } from "@config";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ARedirect to /nodeinfo/2.0
|
||||||
|
*/
|
||||||
|
export default async (
|
||||||
|
req: Request,
|
||||||
|
matchedRoute: MatchedRoute
|
||||||
|
): Promise<Response> => {
|
||||||
|
return new Response("", {
|
||||||
|
status: 301,
|
||||||
|
headers: {
|
||||||
|
Location: `https://${getHost()}/.well-known/nodeinfo/2.0`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { errorResponse, jsonResponse } from "@response";
|
import { errorResponse, jsonResponse } from "@response";
|
||||||
import { APActivity, APCreate, APObject } from "activitypub-types";
|
import {
|
||||||
|
APAccept,
|
||||||
|
APActivity,
|
||||||
|
APCreate,
|
||||||
|
APDelete,
|
||||||
|
APFollow,
|
||||||
|
APObject,
|
||||||
|
APReject,
|
||||||
|
APUpdate,
|
||||||
|
} from "activitypub-types";
|
||||||
import { MatchedRoute } from "bun";
|
import { MatchedRoute } from "bun";
|
||||||
import { RawActivity } from "~database/entities/RawActivity";
|
import { RawActivity } from "~database/entities/RawActivity";
|
||||||
import { RawObject } from "~database/entities/RawObject";
|
import { RawObject } from "~database/entities/RawObject";
|
||||||
|
|
@ -27,6 +36,7 @@ export default async (
|
||||||
case "Create" as APCreate: {
|
case "Create" as APCreate: {
|
||||||
// Body is an APCreate object
|
// Body is an APCreate object
|
||||||
// Store the Create object in database
|
// Store the Create object in database
|
||||||
|
// TODO: Add authentication
|
||||||
|
|
||||||
// Check is Activity already exists
|
// Check is Activity already exists
|
||||||
const exists = await RawActivity.findOneBy({
|
const exists = await RawActivity.findOneBy({
|
||||||
|
|
@ -63,6 +73,52 @@ export default async (
|
||||||
await activity.save();
|
await activity.save();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "Update" as APUpdate: {
|
||||||
|
// Body is an APUpdate object
|
||||||
|
// Replace the object in database with the new provided object
|
||||||
|
// TODO: Add authentication
|
||||||
|
|
||||||
|
const object = await RawObject.findOneBy({
|
||||||
|
data: {
|
||||||
|
id: (body.object as RawObject).id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!object) return errorResponse("Object not found", 404);
|
||||||
|
|
||||||
|
object.data = body.object as APObject;
|
||||||
|
|
||||||
|
await object.save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Delete" as APDelete: {
|
||||||
|
// Body is an APDelete object
|
||||||
|
// Delete the object from database
|
||||||
|
// TODO: Add authentication
|
||||||
|
|
||||||
|
const object = await RawObject.findOneBy({
|
||||||
|
data: {
|
||||||
|
id: (body.object as RawObject).id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!object) return errorResponse("Object not found", 404);
|
||||||
|
|
||||||
|
await object.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Accept" as APAccept: {
|
||||||
|
// Body is an APAccept object
|
||||||
|
// Add the actor to the object actor's followers list
|
||||||
|
// TODO: Add actor to object actor's followers list
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Reject" as APReject: {
|
||||||
|
// Body is an APReject object
|
||||||
|
// Mark the follow request as not pending
|
||||||
|
// TODO: Implement
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonResponse({});
|
return jsonResponse({});
|
||||||
|
|
|
||||||
21
server/api/nodeinfo/2.0/index.ts
Normal file
21
server/api/nodeinfo/2.0/index.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { jsonResponse } from "@response";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub nodeinfo 2.0 endpoint
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/require-await
|
||||||
|
export default async (): Promise<Response> => {
|
||||||
|
// TODO: Implement this
|
||||||
|
return jsonResponse({
|
||||||
|
version: "2.0",
|
||||||
|
software: { name: "fediproject", version: "0.0.1" },
|
||||||
|
protocols: ["activitypub"],
|
||||||
|
services: { outbound: [], inbound: [] },
|
||||||
|
usage: {
|
||||||
|
users: { total: 0, activeMonth: 0, activeHalfyear: 0 },
|
||||||
|
localPosts: 0,
|
||||||
|
},
|
||||||
|
openRegistrations: false,
|
||||||
|
metadata: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -12,6 +12,20 @@ export interface ConfigType {
|
||||||
port: number;
|
port: number;
|
||||||
base_url: string;
|
base_url: string;
|
||||||
};
|
};
|
||||||
|
validation: {
|
||||||
|
max_displayname_size: number;
|
||||||
|
max_bio_size: number;
|
||||||
|
max_username_size: number;
|
||||||
|
max_note_size: number;
|
||||||
|
max_media_size: number;
|
||||||
|
max_media_attachments: number;
|
||||||
|
max_media_description_size: number;
|
||||||
|
|
||||||
|
username_blacklist: string[];
|
||||||
|
blacklist_tempmail: boolean;
|
||||||
|
email_blacklist: string[];
|
||||||
|
url_scheme_whitelist: string[];
|
||||||
|
};
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue