refactor: rename meta columns #10
14 changed files with 60 additions and 27 deletions
|
@ -1,16 +1,22 @@
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
DELETE FROM "migrations" WHERE name IN (
|
DELETE FROM "migrations" WHERE name IN (
|
||||||
|
'RenameMetaColumns1705944717480',
|
||||||
|
'RemoveNativeUtilsMigration1705877093218',
|
||||||
'DropTimeZone1705691683091',
|
'DropTimeZone1705691683091',
|
||||||
'AddReplyMuting1704851359889',
|
'AddReplyMuting1704851359889',
|
||||||
'EmojimodEnumRelabel1699658378432',
|
'EmojimodEnumRelabel1699658378432',
|
||||||
'Vervis1699302371683',
|
'Vervis1699302371683',
|
||||||
'Pgroonga1698420787202',
|
'Pgroonga1698420787202',
|
||||||
'TruncateChartTables1694921638251',
|
'TruncateChartTables1694921638251',
|
||||||
'EmojiModerator1692825433698',
|
'EmojiModerator1692825433698'
|
||||||
'RemoveNativeUtilsMigration1705877093218'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- rename-meta-columns
|
||||||
|
ALTER TABLE "meta" RENAME COLUMN "tosUrl" TO "ToSUrl";
|
||||||
|
ALTER TABLE "meta" RENAME COLUMN "objectStorageUseSsl" TO "objectStorageUseSSL";
|
||||||
|
ALTER TABLE "meta" RENAME COLUMN "customMotd" TO "customMOTD";
|
||||||
|
|
||||||
-- remove-native-utils-migration
|
-- remove-native-utils-migration
|
||||||
CREATE TABLE "seaql_migrations" (
|
CREATE TABLE "seaql_migrations" (
|
||||||
version character varying NOT NULL,
|
version character varying NOT NULL,
|
||||||
|
|
|
@ -70,8 +70,8 @@ pub struct Model {
|
||||||
pub sw_private_key: Option<String>,
|
pub sw_private_key: Option<String>,
|
||||||
#[sea_orm(column_name = "pinnedUsers")]
|
#[sea_orm(column_name = "pinnedUsers")]
|
||||||
pub pinned_users: Vec<String>,
|
pub pinned_users: Vec<String>,
|
||||||
#[sea_orm(column_name = "ToSUrl")]
|
#[sea_orm(column_name = "tosUrl")]
|
||||||
pub to_s_url: Option<String>,
|
pub tos_url: Option<String>,
|
||||||
#[sea_orm(column_name = "repositoryUrl")]
|
#[sea_orm(column_name = "repositoryUrl")]
|
||||||
pub repository_url: String,
|
pub repository_url: String,
|
||||||
#[sea_orm(column_name = "feedbackUrl")]
|
#[sea_orm(column_name = "feedbackUrl")]
|
||||||
|
@ -94,7 +94,7 @@ pub struct Model {
|
||||||
pub object_storage_secret_key: Option<String>,
|
pub object_storage_secret_key: Option<String>,
|
||||||
#[sea_orm(column_name = "objectStoragePort")]
|
#[sea_orm(column_name = "objectStoragePort")]
|
||||||
pub object_storage_port: Option<i32>,
|
pub object_storage_port: Option<i32>,
|
||||||
#[sea_orm(column_name = "objectStorageUseSSL")]
|
#[sea_orm(column_name = "objectStorageUseSsl")]
|
||||||
pub object_storage_use_ssl: bool,
|
pub object_storage_use_ssl: bool,
|
||||||
#[sea_orm(column_name = "proxyAccountId")]
|
#[sea_orm(column_name = "proxyAccountId")]
|
||||||
pub proxy_account_id: Option<String>,
|
pub proxy_account_id: Option<String>,
|
||||||
|
@ -140,7 +140,7 @@ pub struct Model {
|
||||||
pub enable_ip_logging: bool,
|
pub enable_ip_logging: bool,
|
||||||
#[sea_orm(column_name = "enableActiveEmailValidation")]
|
#[sea_orm(column_name = "enableActiveEmailValidation")]
|
||||||
pub enable_active_email_validation: bool,
|
pub enable_active_email_validation: bool,
|
||||||
#[sea_orm(column_name = "customMOTD")]
|
#[sea_orm(column_name = "customMotd")]
|
||||||
pub custom_motd: Vec<String>,
|
pub custom_motd: Vec<String>,
|
||||||
#[sea_orm(column_name = "customSplashIcons")]
|
#[sea_orm(column_name = "customSplashIcons")]
|
||||||
pub custom_splash_icons: Vec<String>,
|
pub custom_splash_icons: Vec<String>,
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
export class RenameMetaColumns1705944717480 {
|
||||||
|
name = "RenameMetaColumns1705944717480";
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "customMOTD" TO "customMotd"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "objectStorageUseSSL" TO "objectStorageUseSsl"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "ToSUrl" TO "tosUrl"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "tosUrl" TO "ToSUrl"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "objectStorageUseSsl" TO "objectStorageUseSSL"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" RENAME COLUMN "customMotd" TO "customMOTD"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,8 +5,8 @@ let cache: Meta;
|
||||||
|
|
||||||
export function metaToPugArgs(meta: Meta): object {
|
export function metaToPugArgs(meta: Meta): object {
|
||||||
let motd = ["Loading..."];
|
let motd = ["Loading..."];
|
||||||
if (meta.customMOTD.length > 0) {
|
if (meta.customMotd.length > 0) {
|
||||||
motd = meta.customMOTD;
|
motd = meta.customMotd;
|
||||||
}
|
}
|
||||||
let splashIconUrl = meta.iconUrl;
|
let splashIconUrl = meta.iconUrl;
|
||||||
if (meta.customSplashIcons.length > 0) {
|
if (meta.customSplashIcons.length > 0) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ export class Meta {
|
||||||
array: true,
|
array: true,
|
||||||
default: "{}",
|
default: "{}",
|
||||||
})
|
})
|
||||||
public customMOTD: string[];
|
public customMotd: string[];
|
||||||
|
|
||||||
@Column("varchar", {
|
@Column("varchar", {
|
||||||
length: 256,
|
length: 256,
|
||||||
|
@ -359,7 +359,7 @@ export class Meta {
|
||||||
length: 512,
|
length: 512,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
public ToSUrl: string | null;
|
public tosUrl: string | null;
|
||||||
|
|
||||||
@Column("jsonb", {
|
@Column("jsonb", {
|
||||||
default: [],
|
default: [],
|
||||||
|
@ -448,7 +448,7 @@ export class Meta {
|
||||||
@Column("boolean", {
|
@Column("boolean", {
|
||||||
default: true,
|
default: true,
|
||||||
})
|
})
|
||||||
public objectStorageUseSSL: boolean;
|
public objectStorageUseSsl: boolean;
|
||||||
|
|
||||||
@Column("boolean", {
|
@Column("boolean", {
|
||||||
default: true,
|
default: true,
|
||||||
|
|
|
@ -294,7 +294,7 @@ import * as ep___pages_update from "./endpoints/pages/update.js";
|
||||||
import * as ep___ping from "./endpoints/ping.js";
|
import * as ep___ping from "./endpoints/ping.js";
|
||||||
import * as ep___recommendedInstances from "./endpoints/recommended-instances.js";
|
import * as ep___recommendedInstances from "./endpoints/recommended-instances.js";
|
||||||
import * as ep___pinnedUsers from "./endpoints/pinned-users.js";
|
import * as ep___pinnedUsers from "./endpoints/pinned-users.js";
|
||||||
import * as ep___customMOTD from "./endpoints/custom-motd.js";
|
import * as ep___customMotd from "./endpoints/custom-motd.js";
|
||||||
import * as ep___customSplashIcons from "./endpoints/custom-splash-icons.js";
|
import * as ep___customSplashIcons from "./endpoints/custom-splash-icons.js";
|
||||||
import * as ep___latestVersion from "./endpoints/latest-version.js";
|
import * as ep___latestVersion from "./endpoints/latest-version.js";
|
||||||
import * as ep___patrons from "./endpoints/patrons.js";
|
import * as ep___patrons from "./endpoints/patrons.js";
|
||||||
|
@ -657,7 +657,7 @@ const eps = [
|
||||||
["reply-mute/create", ep___reply_mute_create],
|
["reply-mute/create", ep___reply_mute_create],
|
||||||
["reply-mute/delete", ep___reply_mute_delete],
|
["reply-mute/delete", ep___reply_mute_delete],
|
||||||
["reply-mute/list", ep___reply_mute_list],
|
["reply-mute/list", ep___reply_mute_list],
|
||||||
["custom-motd", ep___customMOTD],
|
["custom-motd", ep___customMotd],
|
||||||
["custom-splash-icons", ep___customSplashIcons],
|
["custom-splash-icons", ep___customSplashIcons],
|
||||||
["latest-version", ep___latestVersion],
|
["latest-version", ep___latestVersion],
|
||||||
["patrons", ep___patrons],
|
["patrons", ep___patrons],
|
||||||
|
|
|
@ -89,7 +89,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
set.objectStorageSecretKey = config.objectStorage.secretKey;
|
set.objectStorageSecretKey = config.objectStorage.secretKey;
|
||||||
}
|
}
|
||||||
if (typeof config.objectStorage.useSsl === "boolean") {
|
if (typeof config.objectStorage.useSsl === "boolean") {
|
||||||
set.objectStorageUseSSL = config.objectStorage.useSsl;
|
set.objectStorageUseSsl = config.objectStorage.useSsl;
|
||||||
}
|
}
|
||||||
if (typeof config.objectStorage.connnectOverProxy === "boolean") {
|
if (typeof config.objectStorage.connnectOverProxy === "boolean") {
|
||||||
set.objectStorageUseProxy = config.objectStorage.connnectOverProxy;
|
set.objectStorageUseProxy = config.objectStorage.connnectOverProxy;
|
||||||
|
|
|
@ -471,7 +471,7 @@ export default define(meta, paramDef, async () => {
|
||||||
uri: config.url,
|
uri: config.url,
|
||||||
description: instance.description,
|
description: instance.description,
|
||||||
langs: instance.langs,
|
langs: instance.langs,
|
||||||
tosUrl: instance.ToSUrl,
|
tosUrl: instance.tosUrl,
|
||||||
moreUrls: instance.moreUrls,
|
moreUrls: instance.moreUrls,
|
||||||
repositoryUrl: instance.repositoryUrl,
|
repositoryUrl: instance.repositoryUrl,
|
||||||
feedbackUrl: instance.feedbackUrl,
|
feedbackUrl: instance.feedbackUrl,
|
||||||
|
@ -509,7 +509,7 @@ export default define(meta, paramDef, async () => {
|
||||||
defaultReaction: instance.defaultReaction,
|
defaultReaction: instance.defaultReaction,
|
||||||
recommendedInstances: instance.recommendedInstances,
|
recommendedInstances: instance.recommendedInstances,
|
||||||
pinnedUsers: instance.pinnedUsers,
|
pinnedUsers: instance.pinnedUsers,
|
||||||
customMOTD: instance.customMOTD,
|
customMOTD: instance.customMotd,
|
||||||
customSplashIcons: instance.customSplashIcons,
|
customSplashIcons: instance.customSplashIcons,
|
||||||
hiddenTags: instance.hiddenTags,
|
hiddenTags: instance.hiddenTags,
|
||||||
blockedHosts: instance.blockedHosts,
|
blockedHosts: instance.blockedHosts,
|
||||||
|
@ -541,7 +541,7 @@ export default define(meta, paramDef, async () => {
|
||||||
objectStoragePort: instance.objectStoragePort,
|
objectStoragePort: instance.objectStoragePort,
|
||||||
objectStorageAccessKey: instance.objectStorageAccessKey,
|
objectStorageAccessKey: instance.objectStorageAccessKey,
|
||||||
objectStorageSecretKey: instance.objectStorageSecretKey,
|
objectStorageSecretKey: instance.objectStorageSecretKey,
|
||||||
objectStorageUseSSL: instance.objectStorageUseSSL,
|
objectStorageUseSSL: instance.objectStorageUseSsl,
|
||||||
objectStorageUseProxy: instance.objectStorageUseProxy,
|
objectStorageUseProxy: instance.objectStorageUseProxy,
|
||||||
objectStorageSetPublicRead: instance.objectStorageSetPublicRead,
|
objectStorageSetPublicRead: instance.objectStorageSetPublicRead,
|
||||||
objectStorageS3ForcePathStyle: instance.objectStorageS3ForcePathStyle,
|
objectStorageS3ForcePathStyle: instance.objectStorageS3ForcePathStyle,
|
||||||
|
|
|
@ -220,7 +220,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(ps.customMOTD)) {
|
if (Array.isArray(ps.customMOTD)) {
|
||||||
set.customMOTD = ps.customMOTD.filter(Boolean);
|
set.customMotd = ps.customMOTD.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(ps.customSplashIcons)) {
|
if (Array.isArray(ps.customSplashIcons)) {
|
||||||
|
@ -431,7 +431,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.tosUrl !== undefined) {
|
if (ps.tosUrl !== undefined) {
|
||||||
set.ToSUrl = ps.tosUrl;
|
set.tosUrl = ps.tosUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.moreUrls !== undefined) {
|
if (ps.moreUrls !== undefined) {
|
||||||
|
@ -487,7 +487,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.objectStorageUseSSL !== undefined) {
|
if (ps.objectStorageUseSSL !== undefined) {
|
||||||
set.objectStorageUseSSL = ps.objectStorageUseSSL;
|
set.objectStorageUseSsl = ps.objectStorageUseSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.objectStorageUseProxy !== undefined) {
|
if (ps.objectStorageUseProxy !== undefined) {
|
||||||
|
|
|
@ -28,6 +28,6 @@ export const paramDef = {
|
||||||
|
|
||||||
export default define(meta, paramDef, async () => {
|
export default define(meta, paramDef, async () => {
|
||||||
const meta = await fetchMeta();
|
const meta = await fetchMeta();
|
||||||
const motd = await Promise.all(meta.customMOTD.map((x) => x));
|
const motd = await Promise.all(meta.customMotd.map((x) => x));
|
||||||
return motd;
|
return motd;
|
||||||
});
|
});
|
||||||
|
|
|
@ -425,7 +425,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
uri: config.url,
|
uri: config.url,
|
||||||
description: instance.description,
|
description: instance.description,
|
||||||
langs: instance.langs,
|
langs: instance.langs,
|
||||||
tosUrl: instance.ToSUrl,
|
tosUrl: instance.tosUrl,
|
||||||
moreUrls: instance.moreUrls,
|
moreUrls: instance.moreUrls,
|
||||||
repositoryUrl: instance.repositoryUrl,
|
repositoryUrl: instance.repositoryUrl,
|
||||||
feedbackUrl: instance.feedbackUrl,
|
feedbackUrl: instance.feedbackUrl,
|
||||||
|
|
|
@ -74,7 +74,7 @@ const nodeinfo2 = async () => {
|
||||||
email: meta.maintainerEmail,
|
email: meta.maintainerEmail,
|
||||||
},
|
},
|
||||||
langs: meta.langs,
|
langs: meta.langs,
|
||||||
tosUrl: meta.ToSUrl,
|
tosUrl: meta.tosUrl,
|
||||||
repositoryUrl: meta.repositoryUrl,
|
repositoryUrl: meta.repositoryUrl,
|
||||||
feedbackUrl: meta.feedbackUrl,
|
feedbackUrl: meta.feedbackUrl,
|
||||||
disableRegistration: meta.disableRegistration,
|
disableRegistration: meta.disableRegistration,
|
||||||
|
|
|
@ -99,7 +99,7 @@ async function save(
|
||||||
|
|
||||||
const baseUrl = new URL(
|
const baseUrl = new URL(
|
||||||
meta.objectStorageBaseUrl ?? `/${meta.objectStorageBucket}`,
|
meta.objectStorageBaseUrl ?? `/${meta.objectStorageBucket}`,
|
||||||
`${meta.objectStorageUseSSL ? "https" : "http"}://${
|
`${meta.objectStorageUseSsl ? "https" : "http"}://${
|
||||||
meta.objectStorageEndpoint
|
meta.objectStorageEndpoint
|
||||||
}${meta.objectStoragePort ? `:${meta.objectStoragePort}` : ""}`,
|
}${meta.objectStoragePort ? `:${meta.objectStoragePort}` : ""}`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,10 +6,10 @@ import { getAgentByUrl } from "@/misc/fetch.js";
|
||||||
export function getS3(meta: Meta) {
|
export function getS3(meta: Meta) {
|
||||||
const u =
|
const u =
|
||||||
meta.objectStorageEndpoint != null
|
meta.objectStorageEndpoint != null
|
||||||
? `${meta.objectStorageUseSSL ? "https://" : "http://"}${
|
? `${meta.objectStorageUseSsl ? "https://" : "http://"}${
|
||||||
meta.objectStorageEndpoint
|
meta.objectStorageEndpoint
|
||||||
}`
|
}`
|
||||||
: `${meta.objectStorageUseSSL ? "https://" : "http://"}example.net`;
|
: `${meta.objectStorageUseSsl ? "https://" : "http://"}example.net`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new S3({
|
return new S3({
|
||||||
|
@ -17,7 +17,7 @@ export function getS3(meta: Meta) {
|
||||||
accessKeyId: meta.objectStorageAccessKey!,
|
accessKeyId: meta.objectStorageAccessKey!,
|
||||||
secretAccessKey: meta.objectStorageSecretKey!,
|
secretAccessKey: meta.objectStorageSecretKey!,
|
||||||
region: meta.objectStorageRegion || undefined,
|
region: meta.objectStorageRegion || undefined,
|
||||||
sslEnabled: meta.objectStorageUseSSL,
|
sslEnabled: meta.objectStorageUseSsl,
|
||||||
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
|
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
|
||||||
? false
|
? false
|
||||||
: meta.objectStorageS3ForcePathStyle,
|
: meta.objectStorageS3ForcePathStyle,
|
||||||
|
|
Loading…
Reference in a new issue