mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-23 04:33:50 +01:00
Merge pull request 'invalidate local user cache on user update' (#9612) from supakaity/calckey:supakaity/local-user-update into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9612
This commit is contained in:
commit
f3eea3d1c0
@ -1,7 +1,7 @@
|
|||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
import { Users } from "@/models/index.js";
|
import { Users } from "@/models/index.js";
|
||||||
import { User } from "@/models/entities/user.js";
|
|
||||||
import { insertModerationLog } from "@/services/insert-moderation-log.js";
|
import { insertModerationLog } from "@/services/insert-moderation-log.js";
|
||||||
|
import { publishInternalEvent } from "@/services/stream.js";
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ["admin"],
|
tags: ["admin"],
|
||||||
|
|
||||||
@ -29,17 +29,14 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
throw new Error("user is not local user");
|
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, {
|
await Users.update(user.id, {
|
||||||
driveCapacityOverrideMb: ps.overrideMb,
|
driveCapacityOverrideMb: ps.overrideMb,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
publishInternalEvent("localUserUpdated", {
|
||||||
|
id: user.id,
|
||||||
|
});
|
||||||
|
|
||||||
insertModerationLog(me, "change-drive-capacity-override", {
|
insertModerationLog(me, "change-drive-capacity-override", {
|
||||||
targetId: user.id,
|
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 { Antenna } from "@/models/entities/antenna.js";
|
||||||
import type { DriveFile } from "@/models/entities/drive-file.js";
|
import type { DriveFile } from "@/models/entities/drive-file.js";
|
||||||
import type { DriveFolder } from "@/models/entities/drive-folder.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 { UserList } from "@/models/entities/user-list.js";
|
||||||
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
||||||
import type { UserGroup } from "@/models/entities/user-group.js";
|
import type { UserGroup } from "@/models/entities/user-group.js";
|
||||||
@ -23,7 +22,10 @@ export interface InternalStreamTypes {
|
|||||||
id: User["id"];
|
id: User["id"];
|
||||||
isSuspended: User["isSuspended"];
|
isSuspended: User["isSuspended"];
|
||||||
};
|
};
|
||||||
userChangeSilencedState: { id: User["id"]; isSilenced: User["isSilenced"] };
|
userChangeSilencedState: {
|
||||||
|
id: User["id"];
|
||||||
|
isSilenced: User["isSilenced"];
|
||||||
|
};
|
||||||
userChangeModeratorState: {
|
userChangeModeratorState: {
|
||||||
id: User["id"];
|
id: User["id"];
|
||||||
isModerator: User["isModerator"];
|
isModerator: User["isModerator"];
|
||||||
@ -33,7 +35,12 @@ export interface InternalStreamTypes {
|
|||||||
oldToken: User["token"];
|
oldToken: User["token"];
|
||||||
newToken: User["token"];
|
newToken: User["token"];
|
||||||
};
|
};
|
||||||
remoteUserUpdated: { id: User["id"] };
|
localUserUpdated: {
|
||||||
|
id: User["id"];
|
||||||
|
};
|
||||||
|
remoteUserUpdated: {
|
||||||
|
id: User["id"];
|
||||||
|
};
|
||||||
webhookCreated: Webhook;
|
webhookCreated: Webhook;
|
||||||
webhookDeleted: Webhook;
|
webhookDeleted: Webhook;
|
||||||
webhookUpdated: Webhook;
|
webhookUpdated: Webhook;
|
||||||
|
@ -21,6 +21,16 @@ subscriber.on("message", async (_, data) => {
|
|||||||
if (obj.channel === "internal") {
|
if (obj.channel === "internal") {
|
||||||
const { type, body } = obj.message;
|
const { type, body } = obj.message;
|
||||||
switch (type) {
|
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 "userChangeSuspendedState":
|
||||||
case "userChangeSilencedState":
|
case "userChangeSilencedState":
|
||||||
case "userChangeModeratorState":
|
case "userChangeModeratorState":
|
||||||
|
Loading…
Reference in New Issue
Block a user