feat: port monthly scout policy actions
This commit is contained in:
@@ -16,14 +16,26 @@ export const setBlockScout = authedProcedure
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const me = await getMyGeneral(ctx);
|
||||
assertNationAccess(me);
|
||||
const nation = await ctx.db.nation.findUnique({
|
||||
where: { id: me.nationId },
|
||||
select: { meta: true },
|
||||
});
|
||||
const [nation, worldState] = await Promise.all([
|
||||
ctx.db.nation.findUnique({
|
||||
where: { id: me.nationId },
|
||||
select: { meta: true },
|
||||
}),
|
||||
ctx.db.worldState.findFirst({
|
||||
select: { meta: true },
|
||||
}),
|
||||
]);
|
||||
if (!nation) {
|
||||
throw new TRPCError({ code: 'NOT_FOUND', message: 'Nation not found' });
|
||||
}
|
||||
assertNationEditable(me, nation.meta);
|
||||
const worldMeta = asRecord(worldState?.meta);
|
||||
if (worldMeta.block_change_scout === true) {
|
||||
throw new TRPCError({
|
||||
code: 'FORBIDDEN',
|
||||
message: '임관 설정을 바꿀 수 없도록 설정되어 있습니다.',
|
||||
});
|
||||
}
|
||||
const nationMeta = asRecord(nation.meta);
|
||||
await updateNationMeta(
|
||||
ctx,
|
||||
|
||||
Reference in New Issue
Block a user