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 define from "../../define.js";
|
||||||
import { Metas } from "@/models/index.js";
|
import { Metas } from "@/models/index.js";
|
||||||
import { Users } from "@/models/index.js";
|
import { Users } from "@/models/index.js";
|
||||||
|
import { IsNull } from "typeorm";
|
||||||
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -537,10 +538,18 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.autofollowedAccount !== undefined) {
|
if (ps.autofollowedAccount !== undefined) {
|
||||||
// Verify account exists and is a local account
|
if (ps.autofollowedAccount === null) {
|
||||||
const user = await Users.findOneBy({ username: ps.autofollowedAccount, host: null });
|
set.autofollowedAccount = null;
|
||||||
if (user) {
|
}
|
||||||
set.autofollowedAccount = user.username;
|
else {
|
||||||
|
// Verify account exists and is a local account
|
||||||
|
const user = await Users.findOneBy({ username: ps.autofollowedAccount, host: IsNull() });
|
||||||
|
if (user !== null) {
|
||||||
|
set.autofollowedAccount = user.username;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set.autofollowedAccount = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue