mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-08 11:52:55 +01:00
Add more application properties
This commit is contained in:
parent
3a63ae89cc
commit
e807037145
@ -136,6 +136,9 @@
|
|||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"cover_image": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"interactions_endpoint_url": {
|
"interactions_endpoint_url": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -169,6 +172,12 @@
|
|||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"custom_install_url": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"guild_id": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3099,6 +3108,15 @@
|
|||||||
"privacy_policy_url": {
|
"privacy_policy_url": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"guild_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"guild": {
|
||||||
|
"$ref": "#/components/schemas/Guild"
|
||||||
|
},
|
||||||
|
"custom_install_url": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"team": {
|
"team": {
|
||||||
"$ref": "#/components/schemas/Team"
|
"$ref": "#/components/schemas/Team"
|
||||||
},
|
},
|
||||||
|
1224
assets/schemas.json
1224
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -21,6 +21,7 @@ import {
|
|||||||
Application,
|
Application,
|
||||||
ApplicationModifySchema,
|
ApplicationModifySchema,
|
||||||
DiscordApiErrors,
|
DiscordApiErrors,
|
||||||
|
Guild,
|
||||||
handleFile,
|
handleFile,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
@ -90,6 +91,24 @@ router.patch(
|
|||||||
body.icon as string,
|
body.icon as string,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (body.cover_image) {
|
||||||
|
body.cover_image = await handleFile(
|
||||||
|
`/app-icons/${app.id}`,
|
||||||
|
body.cover_image as string,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.guild_id) {
|
||||||
|
const guild = await Guild.findOneOrFail({
|
||||||
|
where: { id: body.guild_id },
|
||||||
|
select: ["owner_id"],
|
||||||
|
});
|
||||||
|
if (guild.owner_id != req.user_id)
|
||||||
|
throw new HTTPError(
|
||||||
|
"You must be the owner of the guild to link it to an application",
|
||||||
|
400,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (app.bot) {
|
if (app.bot) {
|
||||||
app.bot.assign({ bio: body.description });
|
app.bot.assign({ bio: body.description });
|
||||||
|
@ -16,11 +16,19 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToOne,
|
||||||
|
RelationId,
|
||||||
|
} from "typeorm";
|
||||||
import { BaseClass } from "./BaseClass";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Team } from "./Team";
|
import { Team } from "./Team";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import { dbEngine } from "../util/Database";
|
import { dbEngine } from "../util/Database";
|
||||||
|
import { Guild } from "./Guild";
|
||||||
|
|
||||||
@Entity({
|
@Entity({
|
||||||
name: "applications",
|
name: "applications",
|
||||||
@ -108,15 +116,22 @@ export class Application extends BaseClass {
|
|||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
privacy_policy_url?: string;
|
privacy_policy_url?: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
@RelationId((application: Application) => application.guild)
|
||||||
|
guild_id?: string;
|
||||||
|
|
||||||
|
@JoinColumn({ name: "guild_id" })
|
||||||
|
@ManyToOne(() => Guild)
|
||||||
|
guild?: Guild; // guild to which the app is linked, e.g. a developer support server
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
custom_install_url?: string;
|
||||||
|
|
||||||
//just for us
|
//just for us
|
||||||
|
|
||||||
//@Column({ type: "simple-array", nullable: true })
|
//@Column({ type: "simple-array", nullable: true })
|
||||||
//rpc_origins?: string[];
|
//rpc_origins?: string[];
|
||||||
|
|
||||||
//@JoinColumn({ name: "guild_id" })
|
|
||||||
//@ManyToOne(() => Guild)
|
|
||||||
//guild?: Guild; // if this application is a game sold, this field will be the guild to which it has been linked
|
|
||||||
|
|
||||||
//@Column({ nullable: true })
|
//@Column({ nullable: true })
|
||||||
//primary_sku_id?: string; // if this application is a game sold, this field will be the id of the "Game SKU" that is created,
|
//primary_sku_id?: string; // if this application is a game sold, this field will be the id of the "Game SKU" that is created,
|
||||||
|
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class ApplicationProperties1725090962922 implements MigrationInterface {
|
||||||
|
name = "ApplicationProperties1725090962922";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` ADD COLUMN `guild_id` VARCHAR(255) NOT NULL",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` ADD COLUMN `custom_install_url` TEXT NOT NULL",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` DROP COLUMN `guild_id`",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` DROP COLUMN `custom_install_url`",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class ApplicationProperties1725090962922 implements MigrationInterface {
|
||||||
|
name = "ApplicationProperties1725090962922";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` ADD COLUMN `guild_id` VARCHAR(255) NOT NULL",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` ADD COLUMN `custom_install_url` TEXT NOT NULL",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` DROP COLUMN `guild_id`",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE `applications` DROP COLUMN `custom_install_url`",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class ApplicationProperties1725090962922 implements MigrationInterface {
|
||||||
|
name = "ApplicationProperties1725090962922";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE applications ADD COLUMN guild_id TEXT NOT NULL",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE applications ADD COLUMN custom_install_url TEXT NOT NULL",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE applications DROP COLUMN guild_id",
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
"ALTER TABLE applications DROP COLUMN custom_install_url",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published
|
it under the terms of the GNU Affero General Public License as published
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@
|
|||||||
export interface ApplicationModifySchema {
|
export interface ApplicationModifySchema {
|
||||||
description?: string;
|
description?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
|
cover_image?: string;
|
||||||
interactions_endpoint_url?: string;
|
interactions_endpoint_url?: string;
|
||||||
max_participants?: number | null;
|
max_participants?: number | null;
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -29,4 +30,10 @@ export interface ApplicationModifySchema {
|
|||||||
bot_public?: boolean;
|
bot_public?: boolean;
|
||||||
bot_require_code_grant?: boolean;
|
bot_require_code_grant?: boolean;
|
||||||
flags?: number;
|
flags?: number;
|
||||||
|
custom_install_url?: string;
|
||||||
|
guild_id?: string;
|
||||||
|
/*install_params?: { TODO: Validation
|
||||||
|
scopes: string[];
|
||||||
|
permissions: string;
|
||||||
|
};*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user