1
0
Fork 1
mirror of https://example.com synced 2024-11-22 10:56:37 +09:00

refactor: rename meta columns

This commit is contained in:
sup39 2024-01-23 03:53:53 +09:00 committed by naskya
parent e98b8fc2eb
commit 1fca25a8b2
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
14 changed files with 60 additions and 27 deletions

View file

@ -1,16 +1,22 @@
BEGIN;
DELETE FROM "migrations" WHERE name IN (
'RenameMetaColumns1705944717480',
'RemoveNativeUtilsMigration1705877093218',
'DropTimeZone1705691683091',
'AddReplyMuting1704851359889',
'EmojimodEnumRelabel1699658378432',
'Vervis1699302371683',
'Pgroonga1698420787202',
'TruncateChartTables1694921638251',
'EmojiModerator1692825433698',
'RemoveNativeUtilsMigration1705877093218'
'EmojiModerator1692825433698'
);
-- 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
CREATE TABLE "seaql_migrations" (
version character varying NOT NULL,

View file

@ -70,8 +70,8 @@ pub struct Model {
pub sw_private_key: Option<String>,
#[sea_orm(column_name = "pinnedUsers")]
pub pinned_users: Vec<String>,
#[sea_orm(column_name = "ToSUrl")]
pub to_s_url: Option<String>,
#[sea_orm(column_name = "tosUrl")]
pub tos_url: Option<String>,
#[sea_orm(column_name = "repositoryUrl")]
pub repository_url: String,
#[sea_orm(column_name = "feedbackUrl")]
@ -94,7 +94,7 @@ pub struct Model {
pub object_storage_secret_key: Option<String>,
#[sea_orm(column_name = "objectStoragePort")]
pub object_storage_port: Option<i32>,
#[sea_orm(column_name = "objectStorageUseSSL")]
#[sea_orm(column_name = "objectStorageUseSsl")]
pub object_storage_use_ssl: bool,
#[sea_orm(column_name = "proxyAccountId")]
pub proxy_account_id: Option<String>,
@ -140,7 +140,7 @@ pub struct Model {
pub enable_ip_logging: bool,
#[sea_orm(column_name = "enableActiveEmailValidation")]
pub enable_active_email_validation: bool,
#[sea_orm(column_name = "customMOTD")]
#[sea_orm(column_name = "customMotd")]
pub custom_motd: Vec<String>,
#[sea_orm(column_name = "customSplashIcons")]
pub custom_splash_icons: Vec<String>,

View file

@ -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"`,
);
}
}

View file

@ -5,8 +5,8 @@ let cache: Meta;
export function metaToPugArgs(meta: Meta): object {
let motd = ["Loading..."];
if (meta.customMOTD.length > 0) {
motd = meta.customMOTD;
if (meta.customMotd.length > 0) {
motd = meta.customMotd;
}
let splashIconUrl = meta.iconUrl;
if (meta.customSplashIcons.length > 0) {

View file

@ -98,7 +98,7 @@ export class Meta {
array: true,
default: "{}",
})
public customMOTD: string[];
public customMotd: string[];
@Column("varchar", {
length: 256,
@ -359,7 +359,7 @@ export class Meta {
length: 512,
nullable: true,
})
public ToSUrl: string | null;
public tosUrl: string | null;
@Column("jsonb", {
default: [],
@ -448,7 +448,7 @@ export class Meta {
@Column("boolean", {
default: true,
})
public objectStorageUseSSL: boolean;
public objectStorageUseSsl: boolean;
@Column("boolean", {
default: true,

View file

@ -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___recommendedInstances from "./endpoints/recommended-instances.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___latestVersion from "./endpoints/latest-version.js";
import * as ep___patrons from "./endpoints/patrons.js";
@ -657,7 +657,7 @@ const eps = [
["reply-mute/create", ep___reply_mute_create],
["reply-mute/delete", ep___reply_mute_delete],
["reply-mute/list", ep___reply_mute_list],
["custom-motd", ep___customMOTD],
["custom-motd", ep___customMotd],
["custom-splash-icons", ep___customSplashIcons],
["latest-version", ep___latestVersion],
["patrons", ep___patrons],

View file

@ -89,7 +89,7 @@ export default define(meta, paramDef, async (ps, me) => {
set.objectStorageSecretKey = config.objectStorage.secretKey;
}
if (typeof config.objectStorage.useSsl === "boolean") {
set.objectStorageUseSSL = config.objectStorage.useSsl;
set.objectStorageUseSsl = config.objectStorage.useSsl;
}
if (typeof config.objectStorage.connnectOverProxy === "boolean") {
set.objectStorageUseProxy = config.objectStorage.connnectOverProxy;

View file

@ -471,7 +471,7 @@ export default define(meta, paramDef, async () => {
uri: config.url,
description: instance.description,
langs: instance.langs,
tosUrl: instance.ToSUrl,
tosUrl: instance.tosUrl,
moreUrls: instance.moreUrls,
repositoryUrl: instance.repositoryUrl,
feedbackUrl: instance.feedbackUrl,
@ -509,7 +509,7 @@ export default define(meta, paramDef, async () => {
defaultReaction: instance.defaultReaction,
recommendedInstances: instance.recommendedInstances,
pinnedUsers: instance.pinnedUsers,
customMOTD: instance.customMOTD,
customMOTD: instance.customMotd,
customSplashIcons: instance.customSplashIcons,
hiddenTags: instance.hiddenTags,
blockedHosts: instance.blockedHosts,
@ -541,7 +541,7 @@ export default define(meta, paramDef, async () => {
objectStoragePort: instance.objectStoragePort,
objectStorageAccessKey: instance.objectStorageAccessKey,
objectStorageSecretKey: instance.objectStorageSecretKey,
objectStorageUseSSL: instance.objectStorageUseSSL,
objectStorageUseSSL: instance.objectStorageUseSsl,
objectStorageUseProxy: instance.objectStorageUseProxy,
objectStorageSetPublicRead: instance.objectStorageSetPublicRead,
objectStorageS3ForcePathStyle: instance.objectStorageS3ForcePathStyle,

View file

@ -220,7 +220,7 @@ export default define(meta, paramDef, async (ps, me) => {
}
if (Array.isArray(ps.customMOTD)) {
set.customMOTD = ps.customMOTD.filter(Boolean);
set.customMotd = ps.customMOTD.filter(Boolean);
}
if (Array.isArray(ps.customSplashIcons)) {
@ -431,7 +431,7 @@ export default define(meta, paramDef, async (ps, me) => {
}
if (ps.tosUrl !== undefined) {
set.ToSUrl = ps.tosUrl;
set.tosUrl = ps.tosUrl;
}
if (ps.moreUrls !== undefined) {
@ -487,7 +487,7 @@ export default define(meta, paramDef, async (ps, me) => {
}
if (ps.objectStorageUseSSL !== undefined) {
set.objectStorageUseSSL = ps.objectStorageUseSSL;
set.objectStorageUseSsl = ps.objectStorageUseSSL;
}
if (ps.objectStorageUseProxy !== undefined) {

View file

@ -28,6 +28,6 @@ export const paramDef = {
export default define(meta, paramDef, async () => {
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;
});

View file

@ -425,7 +425,7 @@ export default define(meta, paramDef, async (ps, me) => {
uri: config.url,
description: instance.description,
langs: instance.langs,
tosUrl: instance.ToSUrl,
tosUrl: instance.tosUrl,
moreUrls: instance.moreUrls,
repositoryUrl: instance.repositoryUrl,
feedbackUrl: instance.feedbackUrl,

View file

@ -74,7 +74,7 @@ const nodeinfo2 = async () => {
email: meta.maintainerEmail,
},
langs: meta.langs,
tosUrl: meta.ToSUrl,
tosUrl: meta.tosUrl,
repositoryUrl: meta.repositoryUrl,
feedbackUrl: meta.feedbackUrl,
disableRegistration: meta.disableRegistration,

View file

@ -99,7 +99,7 @@ async function save(
const baseUrl = new URL(
meta.objectStorageBaseUrl ?? `/${meta.objectStorageBucket}`,
`${meta.objectStorageUseSSL ? "https" : "http"}://${
`${meta.objectStorageUseSsl ? "https" : "http"}://${
meta.objectStorageEndpoint
}${meta.objectStoragePort ? `:${meta.objectStoragePort}` : ""}`,
);

View file

@ -6,10 +6,10 @@ import { getAgentByUrl } from "@/misc/fetch.js";
export function getS3(meta: Meta) {
const u =
meta.objectStorageEndpoint != null
? `${meta.objectStorageUseSSL ? "https://" : "http://"}${
? `${meta.objectStorageUseSsl ? "https://" : "http://"}${
meta.objectStorageEndpoint
}`
: `${meta.objectStorageUseSSL ? "https://" : "http://"}example.net`;
: `${meta.objectStorageUseSsl ? "https://" : "http://"}example.net`;
try {
return new S3({
@ -17,7 +17,7 @@ export function getS3(meta: Meta) {
accessKeyId: meta.objectStorageAccessKey!,
secretAccessKey: meta.objectStorageSecretKey!,
region: meta.objectStorageRegion || undefined,
sslEnabled: meta.objectStorageUseSSL,
sslEnabled: meta.objectStorageUseSsl,
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
? false
: meta.objectStorageS3ForcePathStyle,