mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-23 04:33:50 +01:00
invalidate local user cache on user update
This commit is contained in:
parent
5925703cc9
commit
4c12faacb1
@ -1,7 +1,7 @@
|
||||
import define from "../../define.js";
|
||||
import { Users } from "@/models/index.js";
|
||||
import { User } from "@/models/entities/user.js";
|
||||
import { insertModerationLog } from "@/services/insert-moderation-log.js";
|
||||
import { publishInternalEvent } from "@/services/stream.js";
|
||||
export const meta = {
|
||||
tags: ["admin"],
|
||||
|
||||
@ -29,17 +29,14 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||
throw new Error("user is not local user");
|
||||
}
|
||||
|
||||
/*if (user.isAdmin) {
|
||||
throw new Error('cannot suspend admin');
|
||||
}
|
||||
if (user.isModerator) {
|
||||
throw new Error('cannot suspend moderator');
|
||||
}*/
|
||||
|
||||
await Users.update(user.id, {
|
||||
driveCapacityOverrideMb: ps.overrideMb,
|
||||
});
|
||||
|
||||
publishInternalEvent("localUserUpdated", {
|
||||
id: user.id,
|
||||
});
|
||||
|
||||
insertModerationLog(me, "change-drive-capacity-override", {
|
||||
targetId: user.id,
|
||||
});
|
||||
|
@ -7,7 +7,6 @@ import type { Note } from "@/models/entities/note.js";
|
||||
import type { Antenna } from "@/models/entities/antenna.js";
|
||||
import type { DriveFile } from "@/models/entities/drive-file.js";
|
||||
import type { DriveFolder } from "@/models/entities/drive-folder.js";
|
||||
import { Emoji } from "@/models/entities/emoji.js";
|
||||
import type { UserList } from "@/models/entities/user-list.js";
|
||||
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
||||
import type { UserGroup } from "@/models/entities/user-group.js";
|
||||
@ -23,7 +22,10 @@ export interface InternalStreamTypes {
|
||||
id: User["id"];
|
||||
isSuspended: User["isSuspended"];
|
||||
};
|
||||
userChangeSilencedState: { id: User["id"]; isSilenced: User["isSilenced"] };
|
||||
userChangeSilencedState: {
|
||||
id: User["id"];
|
||||
isSilenced: User["isSilenced"];
|
||||
};
|
||||
userChangeModeratorState: {
|
||||
id: User["id"];
|
||||
isModerator: User["isModerator"];
|
||||
@ -33,7 +35,12 @@ export interface InternalStreamTypes {
|
||||
oldToken: User["token"];
|
||||
newToken: User["token"];
|
||||
};
|
||||
remoteUserUpdated: { id: User["id"] };
|
||||
localUserUpdated: {
|
||||
id: User["id"];
|
||||
};
|
||||
remoteUserUpdated: {
|
||||
id: User["id"];
|
||||
};
|
||||
webhookCreated: Webhook;
|
||||
webhookDeleted: Webhook;
|
||||
webhookUpdated: Webhook;
|
||||
|
@ -21,6 +21,16 @@ subscriber.on("message", async (_, data) => {
|
||||
if (obj.channel === "internal") {
|
||||
const { type, body } = obj.message;
|
||||
switch (type) {
|
||||
case "localUserUpdated": {
|
||||
userByIdCache.delete(body.id);
|
||||
localUserByIdCache.delete(body.id);
|
||||
localUserByNativeTokenCache.cache.forEach((v, k) => {
|
||||
if (v.value?.id === body.id) {
|
||||
localUserByNativeTokenCache.delete(k);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "userChangeSuspendedState":
|
||||
case "userChangeSilencedState":
|
||||
case "userChangeModeratorState":
|
||||
|
Loading…
Reference in New Issue
Block a user