Repository navigation
feat(notifications): human-readable assigned_task messages - #25
Merged
Merged
Conversation
Replace raw database ids in assignment notifications with a natural sentence
carrying the task title, the project name and the actor:
Fuiste asignado a la tarea «{task_title}» en el proyecto «{project_title}»
por {actor_username}.
- Both assignment sites (task create and reassignment) build the message at the
source, since the offline persistence path stores only the message string.
- Thread the authenticated actor from the router into TaskService.create; the
update path resolves the username from the actor id it already receives.
- Do not notify the actor about their own assignment.
- Fill related_entity_id (task id) so online clients can deep-link later.
- Name resolution is best-effort: any lookup failure falls back to the previous
id-based message and never fails the task mutation.
- Contract unchanged: notification_type stays assigned_task, no DB migration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
B10 of the portfolio fixes, implementing
odd/tasks/notification-messages-spec.md. Notification toasts showed raw database ids (You are assigned to the task 9 in project 3) instead of something a human can act on. The frontend renderspayload.messageverbatim (NotificationToasts.tsx:17->toast.info(p.message)), so the message text is the product.The constraint that shapes the fix
When the assignee is offline,
save_notification_in_dbpersists onlytypeand themessagestring. On reconnect,send_pending_notificationsrebuilds the event from those two columns. Any structured field added to the live payload is therefore dropped for offline users —messageis the only channel that survives both paths. The human-readable text must be built at the source, server-side; the frontend needs zero changes.Changes
Fuiste asignado a la tarea «{task_title}» en el proyecto «{project_title}» por {actor_username}.One phrasing for both paths.
TaskService.createnow receivesactor_user_idandactor_usernamefrom the router; the update path resolves the username from theuser_idit already had.related_entity_id: new optional parameter onformat_notification(core/event_ws.py), passed the task id from both sites. Known limitation (accepted): the offline path drops it.ProjectService.get_project_title_or_nonereturnsNoneon failure and_resolve_usernameswallows lookup errors; the builder then falls back to the previous id-based message.get_project_by_project_idto resolve the title by project id alone (the existingget_project_by_idrequires agroup_idnot available at the notification site).Contract
Unchanged:
notification_typestaysassigned_task, the envelope shape is the same, and there is no DB migration.save_notification_in_dbandsend_pending_notificationsare untouched — the human message flows through both the live and offline paths for free.Out of scope
The seven other raw-id notification sites (comments, groups, projects) — same defect class, tracked separately.
Verification
test/test_services/test_notification_messages.pycovering the human message, self-assignment suppression, the id-based fallback, actor omission, greetingrelated_entity_id, and both create/reassign paths.related_entity_idwiring), so each test genuinely exercises its branch.pytest -q-> 183 passed (was 177; baseline 155).