mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 01:47:39 -07:00
[backend] Fix autofollowedAccount being set to random (possibly non-local) users on update-meta
This commit is contained in:
parent
85cdfb8f33
commit
5a30581c73
1 changed files with 13 additions and 4 deletions
|
@ -4,6 +4,7 @@ import { db } from "@/db/postgre.js";
|
|||
import define from "../../define.js";
|
||||
import { Metas } from "@/models/index.js";
|
||||
import { Users } from "@/models/index.js";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
|
||||
export const meta = {
|
||||
|
@ -537,11 +538,19 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
}
|
||||
|
||||
if (ps.autofollowedAccount !== undefined) {
|
||||
if (ps.autofollowedAccount === null) {
|
||||
set.autofollowedAccount = null;
|
||||
}
|
||||
else {
|
||||
// Verify account exists and is a local account
|
||||
const user = await Users.findOneBy({ username: ps.autofollowedAccount, host: null });
|
||||
if (user) {
|
||||
const user = await Users.findOneBy({ username: ps.autofollowedAccount, host: IsNull() });
|
||||
if (user !== null) {
|
||||
set.autofollowedAccount = user.username;
|
||||
}
|
||||
else {
|
||||
set.autofollowedAccount = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const meta = await Metas.findOne({
|
||||
|
|
Loading…
Reference in a new issue