diff --git a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts index 1f6ac5f27e..c8be344696 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts @@ -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, }); diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index b35c599bde..9becf9f642 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -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; diff --git a/packages/backend/src/services/user-cache.ts b/packages/backend/src/services/user-cache.ts index 1a3b2fc657..9492448554 100644 --- a/packages/backend/src/services/user-cache.ts +++ b/packages/backend/src/services/user-cache.ts @@ -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": diff --git a/packages/client/src/components/global/MkPageHeader.vue b/packages/client/src/components/global/MkPageHeader.vue index f37b2f43f0..28db62c11d 100644 --- a/packages/client/src/components/global/MkPageHeader.vue +++ b/packages/client/src/components/global/MkPageHeader.vue @@ -152,14 +152,16 @@ onMounted(() => { if (tabEl && tabHighlightEl) { // offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある // https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4 - tabEl.addEventListener("transitionend", () => { + function transition() { const parentRect = tabsEl.getBoundingClientRect(); const rect = tabEl.getBoundingClientRect(); const left = (rect.left - parentRect.left + tabsEl?.scrollLeft); tabHighlightEl.style.width = rect.width + 'px'; tabHighlightEl.style.left = left + 'px'; tabsEl?.scrollTo({left: left - 80, behavior: "smooth"}); - }) + tabEl.removeEventListener("transitionend", transition); + } + tabEl.addEventListener("transitionend", transition); } }); }, {