> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Notifications-Collection

`notifications` enthält die Hinweise, die oben im Projekt-Dashboard eines Benutzers angezeigt werden. Ein Dokument ist ein Hinweis für einen Benutzer, identifiziert durch seinen `key`. Nur der Dienst `notifications` greift auf die Collection zu (`services/notifications/app/js/Notifications.js`); `web` und `third-party-datastore` rufen seine HTTP-API auf. Es gibt kein Mongoose-Schema.

#### Felder

| Feld | Typ | Bedeutung | Quelle |
| - | - | - | - |
| `_id` | ObjectId | Hinweis-ID. `web` markiert einen Hinweis über diese ID als gelesen. | `Notifications.js:58-65` |
| `user_id` | ObjectId | Der Benutzer, der den Hinweis sieht. | `Notifications.js:26` |
| `key` | String | Identifiziert den Hinweis, zum Beispiel `project-invite-<inviteId>`. Das Upsert hält ein Dokument pro `user_id` und `key`; es gibt keinen Unique-Index. | `Notifications.js:27`, `:51-55` |
| `templateKey` | String | Welchen Hinweis das Frontend rendert. Wird entfernt, wenn der Hinweis gelesen oder verworfen wird; das Dokument bleibt bestehen. | `Notifications.js:29`, `:63`, `:72`, `:78` |
| `messageOpts` | Object | Werte für den Hinweistext, abhängig von `templateKey` (bei einer Projekteinladung: `userName`, `projectName`, `projectId`, `token`). Wird entfernt, wenn der Benutzer den Hinweis über seine ID verwirft. | `Notifications.js:28`, `:63` |
| `expires` | Date | Optional. Der TTL-Index löscht das Dokument nach diesem Zeitpunkt. | `Notifications.js:35-50` |

#### Wer schreibt

| Code | Was er tut |
| - | - |
| `Notifications.js:20-56` (`addNotification`) | `POST /user/:user_id` (`services/notifications/app.ts:29`). Upsert über `user_id` + `key`. Existiert bereits ein Dokument mit diesem Schlüssel, wird es nur erneut geschrieben, wenn der Aufrufer `forceCreate` sendet. |
| `Notifications.js:58-65` (`removeNotificationId`) | `DELETE /user/:user_id/notification/:notification_id` (`app.ts:31-34`): entfernt `templateKey` und `messageOpts`. |
| `Notifications.js:67-80` | `DELETE /user/:user_id` und `DELETE /key/:key` (`app.ts:35-36`): entfernen `templateKey` über den Schlüssel. |
| `Notifications.js:87-100` | `DELETE /key/:key/bulk` (`app.ts:38-41`) löscht ungelesene Hinweise mit einem Schlüssel; `deleteNotificationByKeyOnly` löscht ein Dokument über den Schlüssel. |
| `services/web/app/src/Features/Notifications/NotificationsHandler.mjs:33-66` | `web`-Seite von `addNotification`. Sendet `forceCreate: true`, sofern der Aufrufer nicht `false` übergibt. |
| `services/third-party-datastore/app/js/QueueWorker.mjs:46-58` | Unsere Dropbox-Synchronisierung: Wenn sie ein Dropbox-Konto trennt, sendet sie den Hinweis `dropbox-unlinked` direkt. |

Hinweise, die CE und unsere Module anlegen:

| `key` | `templateKey` | Angelegt in |
| - | - | - |
| `project-invite-<inviteId>` | `notification_project_invite`, läuft mit der Einladung ab | `services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs:40-42`, aufgebaut in `services/web/app/src/Features/Notifications/NotificationsBuilder.mjs:100-122`. Nur wenn die eingeladene E-Mail-Adresse zu einem vorhandenen Benutzer gehört. |
| `tpdsFileLimit-<userId>` | `notification_tpds_file_limit` | `services/web/app/src/Features/ThirdPartyDataStore/TpdsController.mjs:118-124` (ein Dropbox-Update würde ein Projekt über das Dateilimit bringen), `NotificationsBuilder.mjs:175-195` |
| `dropboxDuplicateProjectNames-<userId>` | `notification_dropbox_duplicate_project_names` | `services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs:160-169`, `NotificationsBuilder.mjs:10-30` |
| `dropbox-unlinked` | `dropbox_unlinked_because_access_denied`, `dropbox_unlinked_because_full` oder `dropbox_unlinked_because_suspended` | `services/third-party-datastore/app/js/QueueWorker.mjs:20-25`, `:46-58` (unsere Dropbox-Synchronisierung) |

`NotificationsBuilder.mjs` baut außerdem Schlüssel für Gruppeneinladungen, Institutionszugehörigkeiten, Abonnements und alte Debug-Projekte. Ihre Aufrufer liegen im Abonnement- und Institutionscode, und die Prüfung auf alte Debug-Projekte läuft nur bei `isSaas` (`services/web/app/src/Features/Project/ProjectListController.mjs:234-236`).

#### Wer liest

| Code | Was er tut |
| - | - |
| `Notifications.js:4-10` (`getUserNotifications`) | `GET /user/:user_id` (`app.ts:30`). Gibt nur die Dokumente des Benutzers zurück, die noch einen `templateKey` haben. |
| `services/web/app/src/Features/Project/ProjectListController.mjs:367` | Lädt die Hinweise für das Projekt-Dashboard. |
| `services/web/app/src/Features/Notifications/NotificationsController.mjs` | `GET /notifications`, `DELETE /notifications/:notificationId` und `GET /user/notification/:notificationId` (`services/web/app/src/router.mjs:922-937`). |
| `services/web/modules/dropbox/app/src/DropboxHandler.mjs:128-131` | Unser Dropbox-Modul: Wenn ein Benutzer Dropbox erneut verknüpft, markiert es `dropbox-unlinked` und `dropboxDuplicateProjectNames-<userId>` als gelesen. |

#### Indizes

| Name | Schlüssel | Optionen | Migration |
| - | - | - | - |
| `expires_1` | `{ expires: 1 }` | TTL, `expireAfterSeconds: 10` | `tools/migrations/20190912145014_create_notifications_indexes.mjs` |
| `key_1` | `{ key: 1 }` | | dieselbe |
| `user_id_1` | `{ user_id: 1 }` | | dieselbe |

#### Hinweise

* Ein gelesener Hinweis wird nicht gelöscht: Nur `templateKey` verschwindet. Da das Dokument den Schlüssel weiterhin enthält, bewirkt ein späteres `addNotification` ohne `forceCreate` für denselben Schlüssel nichts (`Notifications.js:21-24`).
* Die Routen `/key/:key` wirken allein auf den Schlüssel, benutzerübergreifend (`Notifications.js:76-100`).
* Hat `web` keine `apis.notifications.url`, legt es weder Hinweise an noch liest es sie (`NotificationsHandler.mjs:17`, `:41`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.