Skip to content

feat(api): set scheduling InitiatedByUserId on batch and constraint publishes - #242

Merged
noamarg merged 1 commit into
mainfrom
feature/noamarg/97/publish-scheduling-initiator
May 12, 2026
Merged

feat(api): set scheduling InitiatedByUserId on batch and constraint publishes#242
noamarg merged 1 commit into
mainfrom
feature/noamarg/97/publish-scheduling-initiator

Conversation

@noamarg

@noamarg noamarg commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Populates InitiatedByUserId on SchedulePeriodRequest and HandleConstraintChangeRequest using the current JWT user, so asynchronous engine results can be correlated with the triggering operator.

Implementation details

  • ScheduleController: User.GetUserId() on batch enqueue.
  • UserConstraintService / ActivityConstraintService: IHttpContextAccessor + safe resolver for initiator guid.
  • Tests: IHttpContextAccessor mock with null HttpContext where existing tests do not model a request.

Testing

dotnet test tests/Chronos.Tests.MainApi/Chronos.Tests.MainApi.csproj
  • Manually: trigger batch or constraint change; inspect published JSON (optional) for initiatedByUserId in dev.

Risk / rollout

Low. Additive fields on messages; null initiator if unauthenticated or no HTTP context (should not occur for these authorized controller/service entry points in normal operation).

Rollback

Revert PR; messages revert to initiatedByUserId: null; notifications won’t target users until re-deployed.

Files in this PR (only)

  • Chronos.Service/src/Chronos.MainApi/Schedule/Controllers/ScheduleController.cs
  • Chronos.Service/src/Chronos.MainApi/Schedule/Services/UserConstraintService.cs
  • Chronos.Service/src/Chronos.MainApi/Schedule/Services/ActivityConstraintService.cs
  • Chronos.Service/tests/Chronos.Tests.MainApi/Services/Schedule/ActivityConstraintServiceTests.cs
  • Chronos.Service/tests/Chronos.Tests.MainApi/Services/Schedule/UserConstraintServiceTests.cs

@noamarg noamarg self-assigned this May 12, 2026
@noamarg
noamarg requested a review from adamrammal as a code owner May 12, 2026 10:17
@noamarg noamarg added the enhancement New feature or request label May 12, 2026

@adamrammal adamrammal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

@noamarg
noamarg merged commit 9aa1424 into main May 12, 2026
1 check passed
@noamarg
noamarg deleted the feature/noamarg/97/publish-scheduling-initiator branch May 12, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants