mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
Add setting for an autofollowed account on signup
This commit is contained in:
parent
4f9b5d9f72
commit
b814ebcdfb
6 changed files with 75 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddAutofollowedAccount1700686908916 implements MigrationInterface {
|
||||||
|
name = "AddAutofollowedAccount1700686908916";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" ADD "autofollowedAccount" character varying(128)`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "meta" DROP COLUMN "autofollowedAccount"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -518,4 +518,10 @@ export class Meta {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
public donationLink: string | null;
|
public donationLink: string | null;
|
||||||
|
|
||||||
|
@Column("varchar", {
|
||||||
|
length: 64,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public autofollowedAccount: string | null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ import { UsedUsername } from "@/models/entities/used-username.js";
|
||||||
import { db } from "@/db/postgre.js";
|
import { db } from "@/db/postgre.js";
|
||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { hashPassword } from "@/misc/password.js";
|
import { hashPassword } from "@/misc/password.js";
|
||||||
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||||
|
import follow from "@/services/following/create.js";
|
||||||
|
|
||||||
export async function signup(opts: {
|
export async function signup(opts: {
|
||||||
username: User["username"];
|
username: User["username"];
|
||||||
|
@ -133,6 +135,20 @@ export async function signup(opts: {
|
||||||
|
|
||||||
const account = await Users.findOneByOrFail({ id: user.id });
|
const account = await Users.findOneByOrFail({ id: user.id });
|
||||||
|
|
||||||
|
const meta = await fetchMeta();
|
||||||
|
|
||||||
|
// If an autofollow account exists, follow it
|
||||||
|
if (meta.autofollowedAccount) {
|
||||||
|
const autofollowedAccount = await Users.findOneByOrFail({
|
||||||
|
usernameLower: meta.autofollowedAccount.toLowerCase(),
|
||||||
|
host: IsNull(),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (autofollowedAccount) {
|
||||||
|
await follow(account, autofollowedAccount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
usersChart.update(account, true);
|
usersChart.update(account, true);
|
||||||
return { account, secret };
|
return { account, secret };
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,6 +430,11 @@ export const meta = {
|
||||||
optional: true,
|
optional: true,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
},
|
},
|
||||||
|
autofollowedAccount: {
|
||||||
|
type: "string",
|
||||||
|
optional: true,
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -536,5 +541,6 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
enableServerMachineStats: instance.enableServerMachineStats,
|
enableServerMachineStats: instance.enableServerMachineStats,
|
||||||
enableIdenticonGeneration: instance.enableIdenticonGeneration,
|
enableIdenticonGeneration: instance.enableIdenticonGeneration,
|
||||||
donationLink: instance.donationLink,
|
donationLink: instance.donationLink,
|
||||||
|
autofollowedAccount: instance.autofollowedAccount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { insertModerationLog } from "@/services/insert-moderation-log.js";
|
||||||
import { db } from "@/db/postgre.js";
|
import { db } from "@/db/postgre.js";
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
import { Metas } from "@/models/index.js";
|
import { Metas } from "@/models/index.js";
|
||||||
|
import { Users } from "@/models/index.js";
|
||||||
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ["admin"],
|
tags: ["admin"],
|
||||||
|
@ -166,6 +168,7 @@ export const paramDef = {
|
||||||
enableServerMachineStats: { type: "boolean" },
|
enableServerMachineStats: { type: "boolean" },
|
||||||
enableIdenticonGeneration: { type: "boolean" },
|
enableIdenticonGeneration: { type: "boolean" },
|
||||||
donationLink: { type: "string", nullable: true },
|
donationLink: { type: "string", nullable: true },
|
||||||
|
autofollowedAccount: { type: "string", nullable: true },
|
||||||
},
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -547,6 +550,14 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.autofollowedAccount !== undefined) {
|
||||||
|
// Verify account exists and is a local account
|
||||||
|
const user = await Users.findOneBy({ username: ps.autofollowedAccount, host: null });
|
||||||
|
if (user) {
|
||||||
|
set.autofollowedAccount = user.username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const meta = await Metas.findOne({
|
const meta = await Metas.findOne({
|
||||||
where: {},
|
where: {},
|
||||||
order: {
|
order: {
|
||||||
|
|
|
@ -382,6 +382,22 @@
|
||||||
>
|
>
|
||||||
</FormInput>
|
</FormInput>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
|
<FormSection>
|
||||||
|
<template #label>Auto-followed account</template>
|
||||||
|
|
||||||
|
<FormInput
|
||||||
|
v-model="autofollowedAccount"
|
||||||
|
class="_formBlock"
|
||||||
|
>
|
||||||
|
<template #prefix
|
||||||
|
><i class="ph-at ph-bold ph-lg"></i
|
||||||
|
></template>
|
||||||
|
<template #label
|
||||||
|
>Username</template
|
||||||
|
>
|
||||||
|
</FormInput>
|
||||||
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</FormSuspense>
|
</FormSuspense>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
@ -437,6 +453,7 @@ let defaultReaction: string = $ref("");
|
||||||
let defaultReactionCustom: string = $ref("");
|
let defaultReactionCustom: string = $ref("");
|
||||||
let enableServerMachineStats: boolean = $ref(false);
|
let enableServerMachineStats: boolean = $ref(false);
|
||||||
let enableIdenticonGeneration: boolean = $ref(false);
|
let enableIdenticonGeneration: boolean = $ref(false);
|
||||||
|
let autofollowedAccount: string | null = $ref(null);
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const meta = await os.api("admin/meta");
|
const meta = await os.api("admin/meta");
|
||||||
|
@ -478,6 +495,7 @@ async function init() {
|
||||||
: meta.defaultReaction;
|
: meta.defaultReaction;
|
||||||
enableServerMachineStats = meta.enableServerMachineStats;
|
enableServerMachineStats = meta.enableServerMachineStats;
|
||||||
enableIdenticonGeneration = meta.enableIdenticonGeneration;
|
enableIdenticonGeneration = meta.enableIdenticonGeneration;
|
||||||
|
autofollowedAccount = meta.autofollowedAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
@ -517,6 +535,7 @@ function save() {
|
||||||
defaultReaction,
|
defaultReaction,
|
||||||
enableServerMachineStats,
|
enableServerMachineStats,
|
||||||
enableIdenticonGeneration,
|
enableIdenticonGeneration,
|
||||||
|
autofollowedAccount,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
fetchInstance();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue