Runde Bedienelemente, Admin zusammengelegt, Kanäle entfallen
Vier der acht Änderungswünsche. **Knöpfe.** Rund vierzig der siebzig Knöpfe waren blosser Text in Akzentfarbe, von einem Link nicht zu unterscheiden. Jeder trägt jetzt Rahmen und Grundfläche, über die Klasse .btn an einer Stelle definiert statt siebzigmal als Klassenkette. Beim Drücken zieht der Knopf sich zusammen und bekommt einen inneren Ring — er wirkt kurz dicker, ohne dass die Rahmenbreite sich ändert und das Umfeld springt; die Rückmeldung setzt ohne Verzögerung ein und klingt langsam ab, sonst bliebe ein kurzer Klick unsichtbar. Dazu die neue Regel: Flächen bleiben eckig, alles Bedienbare ist rund. Damit ist die Rundung eine Auskunft und keine Verzierung. **Verwaltung.** Rollen, Vorlagen und Änderungsrichtlinie waren drei Einträge in der Kopfzeile für etwas, das man selten und dann zusammenhängend braucht. Jetzt ein Eintrag /admin mit Reiterleiste, dazu eine gemeinsame Tabs-Komponente, die auch der Fallakte zeigt, welcher Reiter offen ist. **Kanäle.** Ersatzlos entfernt, mitsamt Tabelle. Der Chat gehört dorthin, wo der Vorgang steht; ein eigener Reiter mit freien Räumen war der Rückweg nach Discord. Die Personalakte hat jetzt denselben Chat wie die Fallakte — ohne „als Vermerk übernehmen", denn dafür braucht es einen Verlauf, und Meldungen gehen nur an Erwähnte, nie in den allgemeinen Kanal: dass es zu jemandem eine Personalakte gibt, ist selbst eine Auskunft. Ein CHECK erzwingt jetzt, dass eine Nachricht zu genau einem Ort gehört. **Kopfzeile.** Suchbalken statt Suchlink, als gewöhnliches Formular ohne ein Byte im Bündel. Thema, Benachrichtigungen und Abmelden sitzen hinter dem Profilbild, das von Discord kommt; wer keins hat, bekommt seine Initialen. Nebenbei: Aktenzeichen in Tests waren nur auf vier Stellen eindeutig und kollidierten zwischen Läufen, weil Akten nicht löschbar sind. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
bbae8546a0
commit
ef377f0123
@@ -1,29 +1,26 @@
|
||||
import type { Prisma } from '@afis/db'
|
||||
import type { EffectivePermissions } from '@/lib/auth/permissions'
|
||||
import { visibleCaseWhere } from '@/lib/access/caseFilter'
|
||||
import { visiblePersonnelWhere } from '@/lib/access/personnelFilter'
|
||||
|
||||
/**
|
||||
* Chat: Aktenchat und freie Kanäle.
|
||||
* Chat: der formlose Teil, der **an einer Akte hängt**.
|
||||
*
|
||||
* Der Aktenchat erbt die Sichtbarkeit seiner Akte — wer die Akte nicht lesen
|
||||
* darf, sieht auch nicht, dass darüber geredet wird. Ein Kanal hat eine eigene
|
||||
* Mindeststufe.
|
||||
*
|
||||
* Ein Kanal ist kein Geheimnis für sich: dass es ihn gibt, darf jeder sehen,
|
||||
* der seine Stufe hat. Anders als bei Akten gibt es hier keine „Existenz ist
|
||||
* auch eine Information" — ein Raum ohne Zugang wäre sonst nicht auffindbar,
|
||||
* und jemand müsste ihn erraten, um Zugang zu erbitten.
|
||||
* Es gibt keine freien Räume mehr. Ein Chat gehört zu einer Fallakte oder zu
|
||||
* einer Personalakte und erbt deren Sichtbarkeit — wer die Akte nicht lesen
|
||||
* darf, sieht auch nicht, dass darüber geredet wird. Damit gibt es keinen Ort
|
||||
* im System, an dem über einen Vorgang gesprochen werden kann, ohne dass das
|
||||
* Gespräch beim Vorgang steht. Siehe docs/13-entscheidungen.md.
|
||||
*/
|
||||
export function visibleChannelWhere(p: EffectivePermissions): Prisma.ChannelWhereInput {
|
||||
if (p.isAdmin) return {}
|
||||
return { minClearance: { lte: p.clearanceLevel } }
|
||||
}
|
||||
|
||||
export function visibleMessageWhere(p: EffectivePermissions): Prisma.ChatMessageWhereInput {
|
||||
return {
|
||||
OR: [
|
||||
{ case: { is: visibleCaseWhere(p) } },
|
||||
{ channel: { is: visibleChannelWhere(p) } },
|
||||
],
|
||||
const orte: Prisma.ChatMessageWhereInput[] = [{ case: { is: visibleCaseWhere(p) } }]
|
||||
|
||||
// Personalakten setzen zusätzlich zur Stufe ein eigenes Recht voraus. Ohne
|
||||
// das Recht gibt es die Akte für diesen Nutzer nicht, also auch ihren Chat
|
||||
// nicht.
|
||||
if (p.isAdmin || p.permissions.has('personnel.read')) {
|
||||
orte.push({ personnelFile: { is: visiblePersonnelWhere(p) } })
|
||||
}
|
||||
|
||||
return { OR: orte }
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ export type AuditAction =
|
||||
| 'attachment.read'
|
||||
| 'attachment.release'
|
||||
| 'chat.adopt'
|
||||
| 'channel.create'
|
||||
| 'roles.update'
|
||||
| 'export.pdf'
|
||||
| 'export.approve'
|
||||
|
||||
@@ -13,7 +13,7 @@ import type { EffectivePermissions } from '@/lib/auth/permissions'
|
||||
*/
|
||||
export async function loadChatView(p: EffectivePermissions, scope: ChatScope) {
|
||||
const { ort, nachrichten } = await listMessages(p, scope)
|
||||
const scopeId = ort.caseId ?? ort.channelId!
|
||||
const scopeId = ort.caseId ?? ort.personnelFileId!
|
||||
|
||||
const [autoren, vorschauen, reaktionen, lastReadAt, mitglieder] = await Promise.all([
|
||||
db.user.findMany({
|
||||
@@ -22,7 +22,7 @@ export async function loadChatView(p: EffectivePermissions, scope: ChatScope) {
|
||||
}),
|
||||
resolveCasePreviews(p, nachrichten.flatMap((n) => extractCaseNumbers(n.body))),
|
||||
listReactions(p, nachrichten.map((n) => n.id)),
|
||||
loadReadMarker(p, ort.caseId ? 'case' : 'channel', scopeId),
|
||||
loadReadMarker(p, ort.caseId ? 'case' : 'personnel', scopeId),
|
||||
// Für die Anzeige der Erwähnungen: Benutzername auf Anzeigename.
|
||||
db.user.findMany({
|
||||
where: { isActive: true },
|
||||
|
||||
+38
-101
@@ -2,28 +2,32 @@ import { db } from '@/lib/db'
|
||||
import { writeAudit } from '@/lib/audit'
|
||||
import { AccessError, must } from '@/lib/errors'
|
||||
import { visibleCaseWhere } from '@/lib/access/caseFilter'
|
||||
import { visibleChannelWhere, visibleMessageWhere } from '@/lib/access/chatFilter'
|
||||
import { visibleMessageWhere } from '@/lib/access/chatFilter'
|
||||
import { visiblePersonnelWhere } from '@/lib/access/personnelFilter'
|
||||
import { canEditCase } from '@/lib/access/caseWrite'
|
||||
import { extractMentionNames } from '@/lib/chat/mentions'
|
||||
import type { ReactionKey } from '@/lib/chat/terms'
|
||||
import { caseTopic, channelTopic, publish, type Topic } from '@/lib/realtime/publish'
|
||||
import { enqueueCaseNotification } from '@/lib/notify/enqueue'
|
||||
import { caseTopic, personnelTopic, publish, type Topic } from '@/lib/realtime/publish'
|
||||
import { enqueueCaseNotification, enqueuePersonnelNotification } from '@/lib/notify/enqueue'
|
||||
import type { EffectivePermissions } from '@/lib/auth/permissions'
|
||||
import type { Prisma } from '@afis/db'
|
||||
|
||||
/**
|
||||
* Aktenchat und freie Kanäle.
|
||||
* Der Aktenchat.
|
||||
*
|
||||
* Der Chat ist **ausdrücklich kein Aktenbestandteil** — er ist der formlose
|
||||
* Teil, den die Abteilung bisher auf Discord hatte. Deshalb darf hier
|
||||
* bearbeitet und zurückgezogen werden, ohne dass eine Version entsteht.
|
||||
* Er hängt immer an einer Akte — einer Fallakte oder einer Personalakte — und
|
||||
* ist **ausdrücklich kein Aktenbestandteil**: er ist der formlose Teil, den
|
||||
* die Abteilung bisher auf Discord hatte. Deshalb darf hier bearbeitet und
|
||||
* zurückgezogen werden, ohne dass eine Version entsteht.
|
||||
*
|
||||
* Die Brücke zum Aktenbestand ist `adoptAsEntry`: eine Nachricht wird per
|
||||
* Klick zu einem Vermerk. Ab da gelten die harten Regeln der Akte.
|
||||
* Siehe docs/06-chat-und-realtime.md.
|
||||
*/
|
||||
|
||||
export type ChatScope = { kind: 'case'; caseNumber: string } | { kind: 'channel'; key: string }
|
||||
export type ChatScope =
|
||||
| { kind: 'case'; caseNumber: string }
|
||||
| { kind: 'personnel'; fileId: string }
|
||||
|
||||
const NACHRICHT = {
|
||||
id: true,
|
||||
@@ -36,7 +40,7 @@ const NACHRICHT = {
|
||||
mentions: true,
|
||||
createdAt: true,
|
||||
caseId: true,
|
||||
channelId: true,
|
||||
personnelFileId: true,
|
||||
} satisfies Prisma.ChatMessageSelect
|
||||
|
||||
/**
|
||||
@@ -47,7 +51,7 @@ const NACHRICHT = {
|
||||
export async function resolveScope(
|
||||
p: EffectivePermissions,
|
||||
scope: ChatScope,
|
||||
): Promise<{ caseId?: string; channelId?: string; topic: Topic; label: string } | null> {
|
||||
): Promise<{ caseId?: string; personnelFileId?: string; topic: Topic; label: string } | null> {
|
||||
if (scope.kind === 'case') {
|
||||
const akte = await db.case.findFirst({
|
||||
where: { AND: [visibleCaseWhere(p), { caseNumber: scope.caseNumber }] },
|
||||
@@ -56,12 +60,15 @@ export async function resolveScope(
|
||||
return akte ? { caseId: akte.id, topic: caseTopic(akte.id), label: akte.caseNumber } : null
|
||||
}
|
||||
|
||||
const kanal = await db.channel.findFirst({
|
||||
where: { AND: [visibleChannelWhere(p), { key: scope.key, isArchived: false }] },
|
||||
select: { id: true, key: true },
|
||||
// Personalakten setzen neben der Stufe ein eigenes Recht voraus.
|
||||
if (!p.isAdmin && !p.permissions.has('personnel.read')) return null
|
||||
|
||||
const akte = await db.personnelFile.findFirst({
|
||||
where: { AND: [visiblePersonnelWhere(p), { id: scope.fileId }] },
|
||||
select: { id: true, displayName: true },
|
||||
})
|
||||
return kanal
|
||||
? { channelId: kanal.id, topic: channelTopic(kanal.id), label: kanal.key }
|
||||
return akte
|
||||
? { personnelFileId: akte.id, topic: personnelTopic(akte.id), label: akte.displayName }
|
||||
: null
|
||||
}
|
||||
|
||||
@@ -82,7 +89,7 @@ export async function listMessages(
|
||||
|
||||
const wo: Prisma.ChatMessageWhereInput = ort.caseId
|
||||
? { caseId: ort.caseId }
|
||||
: { channelId: ort.channelId }
|
||||
: { personnelFileId: ort.personnelFileId }
|
||||
|
||||
const nachrichten = await db.chatMessage.findMany({
|
||||
where: { AND: [wo, ...(options.since ? [{ id: { gt: options.since } }] : [])] },
|
||||
@@ -149,7 +156,7 @@ export async function sendMessage(
|
||||
const ziel = await db.chatMessage.findFirst({
|
||||
where: {
|
||||
id: input.replyToId,
|
||||
...(ort.caseId ? { caseId: ort.caseId } : { channelId: ort.channelId }),
|
||||
...(ort.caseId ? { caseId: ort.caseId } : { personnelFileId: ort.personnelFileId }),
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
@@ -161,7 +168,7 @@ export async function sendMessage(
|
||||
data: {
|
||||
id: input.id,
|
||||
caseId: ort.caseId ?? null,
|
||||
channelId: ort.channelId ?? null,
|
||||
personnelFileId: ort.personnelFileId ?? null,
|
||||
authorId: p.userId,
|
||||
body: text,
|
||||
replyToId,
|
||||
@@ -188,18 +195,15 @@ export async function sendMessage(
|
||||
onlyFor: erwaehnt.length > 0 ? erwaehnt.map((u) => u.id) : undefined,
|
||||
meta: { messageId: nachricht.id },
|
||||
})
|
||||
} else if (erwaehnt.length > 0) {
|
||||
// In einem Kanal gibt es keine Akte, deren Sichtbarkeit zu prüfen wäre.
|
||||
// Die Mindeststufe des Kanals hat der Absender schon passiert, und
|
||||
// erwähnt wird nur, wer sie ebenfalls hat.
|
||||
await tx.notificationOutbox.createMany({
|
||||
data: erwaehnt.map((user) => ({
|
||||
kind: 'chat.mention',
|
||||
channelId: ort.channelId,
|
||||
actorId: p.userId,
|
||||
recipientId: user.id,
|
||||
meta: { messageId: nachricht.id, channelKey: ort.label, actorName: absenderName },
|
||||
})),
|
||||
} else if (ort.personnelFileId) {
|
||||
// Im Chat einer Personalakte geht nur an ausdrücklich Erwähnte etwas
|
||||
// hinaus, und auch das nur an die, die die Akte lesen dürfen.
|
||||
await enqueuePersonnelNotification(tx, {
|
||||
personnelFileId: ort.personnelFileId,
|
||||
actorId: p.userId,
|
||||
actorName: absenderName,
|
||||
mentioned: erwaehnt.map((user) => user.id),
|
||||
meta: { messageId: nachricht.id },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -378,9 +382,9 @@ export async function adoptAsEntry(
|
||||
return { entryId }
|
||||
}
|
||||
|
||||
function themaVon(nachricht: { caseId: string | null; channelId: string | null }): Topic {
|
||||
function themaVon(nachricht: { caseId: string | null; personnelFileId: string | null }): Topic {
|
||||
if (nachricht.caseId) return caseTopic(nachricht.caseId)
|
||||
return channelTopic(nachricht.channelId!)
|
||||
return personnelTopic(nachricht.personnelFileId!)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -396,7 +400,7 @@ function themaVon(nachricht: { caseId: string | null; channelId: string | null }
|
||||
*/
|
||||
export async function loadReadMarker(
|
||||
p: EffectivePermissions,
|
||||
scopeType: 'case' | 'channel',
|
||||
scopeType: 'case' | 'personnel',
|
||||
scopeId: string,
|
||||
): Promise<Date | null> {
|
||||
const marker = await db.readMarker.findUnique({
|
||||
@@ -408,7 +412,7 @@ export async function loadReadMarker(
|
||||
|
||||
export async function markRead(
|
||||
p: EffectivePermissions,
|
||||
scopeType: 'case' | 'channel',
|
||||
scopeType: 'case' | 'personnel',
|
||||
scopeId: string,
|
||||
at: Date = new Date(),
|
||||
): Promise<void> {
|
||||
@@ -418,70 +422,3 @@ export async function markRead(
|
||||
update: { lastReadAt: at },
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Kanäle
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Die Kanäle, die dieser Nutzer sehen darf. */
|
||||
export async function listChannels(p: EffectivePermissions) {
|
||||
return db.channel.findMany({
|
||||
where: { AND: [visibleChannelWhere(p), { isArchived: false }] },
|
||||
orderBy: { name: 'asc' },
|
||||
select: {
|
||||
id: true,
|
||||
key: true,
|
||||
name: true,
|
||||
description: true,
|
||||
minClearance: true,
|
||||
createdAt: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Kanal anlegen.
|
||||
*
|
||||
* Die Mindeststufe lässt sich nicht über die eigene heben — sonst legte
|
||||
* jemand einen Raum an, den er selbst nicht mehr betreten kann, und dieselbe
|
||||
* Regel gilt schon bei Akten und Dokumenten.
|
||||
*/
|
||||
export async function createChannel(
|
||||
p: EffectivePermissions,
|
||||
input: { key: string; name: string; description?: string | null; minClearance: number },
|
||||
): Promise<{ key: string }> {
|
||||
if (!p.isAdmin && !p.permissions.has('case.create')) throw new AccessError('no-permission')
|
||||
if (input.minClearance > p.clearanceLevel && !p.isAdmin) {
|
||||
throw new AccessError('clearance-too-low')
|
||||
}
|
||||
|
||||
const key = input.key.trim().toLowerCase()
|
||||
if (!/^[a-z0-9][a-z0-9-]{1,40}$/.test(key)) throw new AccessError('channel-key-invalid')
|
||||
|
||||
const vorhanden = await db.channel.findUnique({ where: { key }, select: { id: true } })
|
||||
if (vorhanden) throw new AccessError('channel-key-taken')
|
||||
|
||||
return db.$transaction(async (tx) => {
|
||||
const kanal = await tx.channel.create({
|
||||
data: {
|
||||
key,
|
||||
name: input.name.trim().slice(0, 120),
|
||||
description: input.description?.trim() || null,
|
||||
minClearance: input.minClearance,
|
||||
createdById: p.userId,
|
||||
},
|
||||
select: { key: true },
|
||||
})
|
||||
|
||||
await writeAudit(tx, {
|
||||
actorId: p.userId,
|
||||
action: 'channel.create',
|
||||
targetType: 'Channel',
|
||||
targetId: kanal.key,
|
||||
clearanceAtTime: p.clearanceLevel,
|
||||
meta: { key: kanal.key, minClearance: input.minClearance },
|
||||
})
|
||||
|
||||
return kanal
|
||||
})
|
||||
}
|
||||
|
||||
+27
-20
@@ -1,6 +1,7 @@
|
||||
import { db } from '@/lib/db'
|
||||
import { visibleCaseWhere } from '@/lib/access/caseFilter'
|
||||
import { visibleMessageWhere } from '@/lib/access/chatFilter'
|
||||
import { visiblePersonnelWhere } from '@/lib/access/personnelFilter'
|
||||
import { listWatched } from '@/lib/cases/watch'
|
||||
import { listRecent } from '@/lib/recent/service'
|
||||
import type { EffectivePermissions } from '@/lib/auth/permissions'
|
||||
@@ -73,7 +74,7 @@ export async function loadDashboard(p: EffectivePermissions) {
|
||||
}
|
||||
|
||||
export type UnreadChat = {
|
||||
scopeType: 'case' | 'channel'
|
||||
scopeType: 'case' | 'personnel'
|
||||
scopeId: string
|
||||
label: string
|
||||
href: string
|
||||
@@ -83,10 +84,10 @@ export type UnreadChat = {
|
||||
/**
|
||||
* Wo seit dem letzten Besuch geschrieben wurde.
|
||||
*
|
||||
* Gezählt wird über `ReadMarker`. Nur an Orten, an denen der Nutzer beteiligt
|
||||
* ist, die er beobachtet, oder in Kanälen, die er sehen darf — eine Zählung
|
||||
* über alle sichtbaren Akten wäre auf der Übersicht nur Lärm. Eigene
|
||||
* Nachrichten zählen nicht mit.
|
||||
* Gezählt wird über `ReadMarker`. Nur an Orten, die den Nutzer angehen: Akten,
|
||||
* an denen er beteiligt ist oder die er beobachtet, und Personalakten, denen
|
||||
* er zugeordnet ist. Eine Zählung über alles Sichtbare wäre auf der Übersicht
|
||||
* nur Lärm. Eigene Nachrichten zählen nicht mit.
|
||||
*/
|
||||
async function ungeleseneChats(p: EffectivePermissions): Promise<UnreadChat[]> {
|
||||
const marken = await db.readMarker.findMany({
|
||||
@@ -95,7 +96,9 @@ async function ungeleseneChats(p: EffectivePermissions): Promise<UnreadChat[]> {
|
||||
})
|
||||
const markeVon = new Map(marken.map((m) => [`${m.scopeType}:${m.scopeId}`, m.lastReadAt]))
|
||||
|
||||
const [meineAkten, kanaele] = await Promise.all([
|
||||
const darfPersonal = p.isAdmin || p.permissions.has('personnel.read')
|
||||
|
||||
const [meineAkten, personalakten] = await Promise.all([
|
||||
db.case.findMany({
|
||||
where: {
|
||||
AND: [
|
||||
@@ -111,14 +114,18 @@ async function ungeleseneChats(p: EffectivePermissions): Promise<UnreadChat[]> {
|
||||
select: { id: true, caseNumber: true },
|
||||
take: 50,
|
||||
}),
|
||||
db.channel.findMany({
|
||||
where: {
|
||||
isArchived: false,
|
||||
...(p.isAdmin ? {} : { minClearance: { lte: p.clearanceLevel } }),
|
||||
},
|
||||
select: { id: true, key: true },
|
||||
take: 50,
|
||||
}),
|
||||
darfPersonal
|
||||
? db.personnelFile.findMany({
|
||||
where: {
|
||||
AND: [
|
||||
visiblePersonnelWhere(p),
|
||||
{ assignments: { some: { userId: p.userId } } },
|
||||
],
|
||||
},
|
||||
select: { id: true, displayName: true },
|
||||
take: 50,
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
])
|
||||
|
||||
const orte = [
|
||||
@@ -129,12 +136,12 @@ async function ungeleseneChats(p: EffectivePermissions): Promise<UnreadChat[]> {
|
||||
href: `/faelle/${akte.caseNumber}`,
|
||||
wo: { caseId: akte.id } as Prisma.ChatMessageWhereInput,
|
||||
})),
|
||||
...kanaele.map((kanal) => ({
|
||||
scopeType: 'channel' as const,
|
||||
scopeId: kanal.id,
|
||||
label: `#${kanal.key}`,
|
||||
href: `/kanaele/${kanal.key}`,
|
||||
wo: { channelId: kanal.id } as Prisma.ChatMessageWhereInput,
|
||||
...personalakten.map((akte) => ({
|
||||
scopeType: 'personnel' as const,
|
||||
scopeId: akte.id,
|
||||
label: akte.displayName,
|
||||
href: `/personalakten/${akte.id}`,
|
||||
wo: { personnelFileId: akte.id } as Prisma.ChatMessageWhereInput,
|
||||
})),
|
||||
]
|
||||
if (orte.length === 0) return []
|
||||
|
||||
@@ -39,7 +39,6 @@ export async function exportDatabase(p: EffectivePermissions): Promise<Uint8Arra
|
||||
documentSections,
|
||||
documentSectionVersions,
|
||||
attachments,
|
||||
channels,
|
||||
messages,
|
||||
reactions,
|
||||
auditLog,
|
||||
@@ -64,7 +63,6 @@ export async function exportDatabase(p: EffectivePermissions): Promise<Uint8Arra
|
||||
db.documentSection.findMany(),
|
||||
db.documentSectionVersion.findMany(),
|
||||
db.attachment.findMany(),
|
||||
db.channel.findMany(),
|
||||
db.chatMessage.findMany(),
|
||||
db.chatReaction.findMany(),
|
||||
// Das Protokoll gehört dazu: ein Abzug ohne die Zugriffsspur wäre als
|
||||
@@ -96,7 +94,6 @@ export async function exportDatabase(p: EffectivePermissions): Promise<Uint8Arra
|
||||
documentSections,
|
||||
documentSectionVersions,
|
||||
attachments,
|
||||
channels,
|
||||
messages,
|
||||
reactions,
|
||||
auditLog,
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
export const adminText = {
|
||||
heading: 'Admin',
|
||||
intro: 'Rollen, Vorlagen, Regeln und das Protokoll der Abteilung.',
|
||||
sections: {
|
||||
roles: 'Rollen',
|
||||
templates: 'Vorlagen',
|
||||
policy: 'Änderungsrichtlinie',
|
||||
log: 'Protokoll',
|
||||
system: 'System',
|
||||
} as Record<string, string>,
|
||||
descriptions: {
|
||||
roles: 'Welche Discord-Rolle welche Freigabestufe und welche Rechte trägt.',
|
||||
templates: 'Aufbau der Fallakten und Dokumente, Bausteine und Fassungen.',
|
||||
policy: 'Ob und wie lange Verlaufseinträge nachträglich geändert werden dürfen.',
|
||||
log: 'Wer was wo getan hat. Vollständig und nicht änderbar.',
|
||||
system: 'Zustand der Dienste, Ladewerte, Nummernkreise.',
|
||||
} as Record<string, string>,
|
||||
empty: 'Für die Verwaltung fehlen dir die Rechte. Die Abteilungsleitung vergibt sie.',
|
||||
} as const
|
||||
|
||||
/**
|
||||
* Der Adminbereich: Rollen, Vorlagen, Einstellungen.
|
||||
*
|
||||
|
||||
@@ -44,21 +44,3 @@ export const chatText = {
|
||||
wichtig: '▲',
|
||||
} as Record<string, string>,
|
||||
} as const
|
||||
|
||||
export const channelText = {
|
||||
one: 'Kanal',
|
||||
many: 'Kanäle',
|
||||
heading: 'Kanäle',
|
||||
intro: 'Freie Räume für Absprachen, die zu keiner Akte gehören.',
|
||||
empty: 'Noch kein Kanal. Ersten Kanal anlegen.',
|
||||
create: 'Kanal anlegen',
|
||||
createTitle: 'Neuer Kanal',
|
||||
name: 'Name',
|
||||
key: 'Kürzel',
|
||||
keyHint: 'Kleinbuchstaben, Ziffern und Bindestrich. Steht später in der Adresse.',
|
||||
description: 'Beschreibung',
|
||||
minClearance: 'Mindeststufe',
|
||||
minClearanceHint: 'Wer diese Stufe nicht hat, sieht den Kanal nicht.',
|
||||
archived: 'Archiviert',
|
||||
open: 'Öffnen',
|
||||
} as const
|
||||
|
||||
@@ -43,9 +43,7 @@ export const actionErrorsText = {
|
||||
'message-too-long': 'Die Nachricht ist länger als 4000 Zeichen.',
|
||||
'message-withdrawn': 'Die Nachricht wurde zurückgezogen.',
|
||||
'adopt-needs-case': 'Nur eine Nachricht aus einem Aktenchat wird zum Vermerk.',
|
||||
'channel-key-taken': 'Dieses Kürzel gibt es schon.',
|
||||
'too-many-views': 'Mehr als dreissig Ansichten werden unübersichtlich. Lösche eine.',
|
||||
'channel-key-invalid': 'Kürzel: Kleinbuchstaben, Ziffern und Bindestrich, mindestens zwei Zeichen.',
|
||||
default: 'Nicht gespeichert. Erneut versuchen.',
|
||||
} as Record<string, string>
|
||||
|
||||
|
||||
+13
-3
@@ -24,6 +24,8 @@ import {
|
||||
searchText,
|
||||
paletteText,
|
||||
themeText,
|
||||
profileText,
|
||||
searchBarText,
|
||||
dashboardText,
|
||||
watchText,
|
||||
} from '@/lib/i18n/shell'
|
||||
@@ -35,17 +37,24 @@ import {
|
||||
participantText,
|
||||
linkText,
|
||||
} from '@/lib/i18n/cases'
|
||||
import { chatText, channelText } from '@/lib/i18n/chat'
|
||||
import { chatText } from '@/lib/i18n/chat'
|
||||
import { personnelText, assignmentText } from '@/lib/i18n/people'
|
||||
import { documentText, attachmentText } from '@/lib/i18n/documents'
|
||||
import { exportText } from '@/lib/i18n/export'
|
||||
import { roleAdminText, templateAdminText, settingsText, vitalsText } from '@/lib/i18n/admin'
|
||||
import {
|
||||
adminText,
|
||||
roleAdminText,
|
||||
templateAdminText,
|
||||
settingsText,
|
||||
vitalsText,
|
||||
} from '@/lib/i18n/admin'
|
||||
|
||||
export const de = {
|
||||
app: appText,
|
||||
nav: navText,
|
||||
auth: authText,
|
||||
overview: overviewText,
|
||||
admin: adminText,
|
||||
roleAdmin: roleAdminText,
|
||||
clearance: clearanceText,
|
||||
case: caseText,
|
||||
@@ -56,7 +65,6 @@ export const de = {
|
||||
participant: participantText,
|
||||
link: linkText,
|
||||
chat: chatText,
|
||||
channel: channelText,
|
||||
document: documentText,
|
||||
attachment: attachmentText,
|
||||
export: exportText,
|
||||
@@ -71,6 +79,8 @@ export const de = {
|
||||
search: searchText,
|
||||
palette: paletteText,
|
||||
theme: themeText,
|
||||
profile: profileText,
|
||||
searchBar: searchBarText,
|
||||
dashboard: dashboardText,
|
||||
watch: watchText,
|
||||
} as const
|
||||
|
||||
+11
-2
@@ -21,7 +21,7 @@ export const navText = {
|
||||
cases: 'Fallakten',
|
||||
personnel: 'Personalakten',
|
||||
search: 'Suche',
|
||||
admin: 'Verwaltung',
|
||||
admin: 'Admin',
|
||||
skipToContent: 'Zum Inhalt springen',
|
||||
} as const
|
||||
|
||||
@@ -178,12 +178,21 @@ export const paletteText = {
|
||||
{ href: '/faelle', label: 'Fallakten' },
|
||||
{ href: '/faelle/neu', label: 'Neue Fallakte' },
|
||||
{ href: '/personalakten', label: 'Personalakten' },
|
||||
{ href: '/kanaele', label: 'Kanäle' },
|
||||
{ href: '/suche', label: 'Suche' },
|
||||
{ href: '/einstellungen', label: 'Benachrichtigungen' },
|
||||
],
|
||||
} as const
|
||||
|
||||
export const profileText = {
|
||||
open: 'Konto und Einstellungen',
|
||||
signedInAs: 'Angemeldet als',
|
||||
} as const
|
||||
|
||||
export const searchBarText = {
|
||||
label: 'Suchen',
|
||||
placeholder: 'Aktenzeichen, Titel, Name',
|
||||
} as const
|
||||
|
||||
export const themeText = {
|
||||
label: 'Thema',
|
||||
system: 'Wie das System',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { db } from '@/lib/db'
|
||||
import { READ_AUDIT_FROM_LEVEL } from '@/lib/audit'
|
||||
import { visibleCaseWhere } from '@/lib/access/caseFilter'
|
||||
import { visiblePersonnelWhere } from '@/lib/access/personnelFilter'
|
||||
import { resolvePermissions } from '@/lib/auth/effective'
|
||||
import type { Prisma } from '@afis/db'
|
||||
|
||||
@@ -122,3 +123,63 @@ export async function enqueueCaseNotification(
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Meldung aus dem Chat einer Personalakte.
|
||||
*
|
||||
* Zwei Unterschiede zur Fallakte, beide bewusst:
|
||||
*
|
||||
* 1. **Nur an ausdrücklich Erwähnte**, nie in den allgemeinen Kanal. Dass es
|
||||
* zu einer bestimmten Person eine Akte gibt, ist selbst eine Auskunft, und
|
||||
* die gehört nicht in einen Raum, in dem alle mitlesen.
|
||||
* 2. **Kein Name in der Meldung.** Weder der der Person noch der Text. Der
|
||||
* Link führt in die Anwendung, und die prüft selbst.
|
||||
*
|
||||
* Geprüft wird je Empfänger mit derselben Abfrage wie beim Lesen, plus dem
|
||||
* Recht `personnel.read` — ohne das gibt es die Akte für ihn nicht.
|
||||
*/
|
||||
export async function enqueuePersonnelNotification(
|
||||
tx: Prisma.TransactionClient,
|
||||
input: {
|
||||
personnelFileId: string
|
||||
actorId: string
|
||||
actorName: string
|
||||
mentioned: string[]
|
||||
meta?: Record<string, unknown>
|
||||
},
|
||||
): Promise<void> {
|
||||
if (input.mentioned.length === 0) return
|
||||
|
||||
const kandidaten = await db.user.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
notifyMode: { not: 'OFF' },
|
||||
id: { in: input.mentioned, not: input.actorId },
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
|
||||
const ziele: string[] = []
|
||||
for (const nutzer of kandidaten) {
|
||||
const rechte = await resolvePermissions(nutzer.id)
|
||||
if (!rechte.isAdmin && !rechte.permissions.has('personnel.read')) continue
|
||||
|
||||
const sichtbar = await db.personnelFile.findFirst({
|
||||
where: { AND: [visiblePersonnelWhere(rechte), { id: input.personnelFileId }] },
|
||||
select: { id: true },
|
||||
})
|
||||
if (sichtbar) ziele.push(nutzer.id)
|
||||
}
|
||||
|
||||
if (ziele.length === 0) return
|
||||
|
||||
await tx.notificationOutbox.createMany({
|
||||
data: ziele.map((ziel) => ({
|
||||
kind: 'chat.mention',
|
||||
personnelFileId: input.personnelFileId,
|
||||
actorId: input.actorId,
|
||||
recipientId: ziel,
|
||||
meta: { actorName: input.actorName, ...input.meta } as Prisma.InputJsonValue,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ export type EventKind =
|
||||
| 'export.ready'
|
||||
|
||||
/** Wer das Ereignis angeht. */
|
||||
export type Topic = `case:${string}` | `channel:${string}` | `user:${string}`
|
||||
export type Topic = `case:${string}` | `personnel:${string}` | `user:${string}`
|
||||
|
||||
export function caseTopic(caseId: string): Topic {
|
||||
return `case:${caseId}`
|
||||
}
|
||||
export function channelTopic(channelId: string): Topic {
|
||||
return `channel:${channelId}`
|
||||
export function personnelTopic(fileId: string): Topic {
|
||||
return `personnel:${fileId}`
|
||||
}
|
||||
export function userTopic(userId: string): Topic {
|
||||
return `user:${userId}`
|
||||
|
||||
Reference in New Issue
Block a user