Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CU-8687aj3gt Trying to fix User Push reg issue.#241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ucswift merged 1 commit intomasterfromdevelop
Aug 28, 2025
Merged

Conversation

@ucswift
Copy link
Member

@ucswiftucswift commentedAug 28, 2025
edited by coderabbitaibot
Loading

Summary by CodeRabbit

  • New Features
    • Device registration now supports an optional custom Push Location prefix; if not provided, it defaults to the department code.
  • Bug Fixes
    • Strengthened device registration validation to prevent empty Push Location values, improving reliability of push routing.

@request-info
Copy link

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@coderabbitai
Copy link
Contributor

coderabbitaibot commentedAug 28, 2025
edited
Loading

Walkthrough

This change simplifies PushUri.PushLocation to an auto-property, adds a non-empty PushLocation requirement during registration, and updates device registration to set PushLocation from an optional Prefix or fallback to the department code.

Changes

Cohort / File(s)Summary
Model: PushUri property simplification
Core/Resgrid.Model/PushUri.cs
Replaced custom PushLocation with[ProtoMember(9)] public string PushLocation { get; set; }; removed backing field and[Required]; eliminated setter side effects.
Service: Registration validation
Core/Resgrid.Services/PushService.cs
InPushService.Register, addedstring.IsNullOrWhiteSpace(pushUri.PushLocation) to the guard; registration now requires non-empty PushLocation.
API: Device registration logic
Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs
InRegisterDevice, PushLocation now set toregistrationInput.Prefix if provided; otherwise fetched via department and set todepartment.Code (previously always used department code).

Sequence Diagram(s)

sequenceDiagram  autonumber  participant Client  participant DevicesController  participant DeptRepo as Department Repository  participant PushService  Client->>DevicesController: POST /v4/devices/register (registrationInput)  alt Prefix provided    DevicesController->>DevicesController: PushLocation = Prefix  else No Prefix    DevicesController->>DeptRepo: GetById(DepartmentId)    DeptRepo-->>DevicesController: Department(code)    DevicesController->>DevicesController: PushLocation = department.code  end  DevicesController->>PushService: Register(pushUri)  PushService->>PushService: Validate DeviceId && PushLocation not empty  alt Validation fails    PushService-->>DevicesController: false    DevicesController-->>Client: 400/Failure  else Validation passes    PushService-->>DevicesController: true    DevicesController-->>Client: 200/Success  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump and hop through fields of code,
Set PushLocation on the road—
Prefix first, or dept we choose,
With tidy props that never bruise.
Guards in place, no sneaky flight,
Devices register just right. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from theIntegrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branchdevelop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag@coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type@coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add@coderabbit ignore or@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbit summary or@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbit or@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit ourStatus Page to check the current availability of CodeRabbit.
  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs (1)

63-67:Unit registration will fail validation (empty PushLocation); use the same fallback as RegisterDevice.

PushService.RegisterUnit requires PushLocation to be non-empty. Setting it to "" will cause the registration to be dropped.

-if (!string.IsNullOrWhiteSpace(registrationInput.Prefix))-pushRegisterionEvent.PushLocation = registrationInput.Prefix;-else-pushRegisterionEvent.PushLocation = "";+if (!string.IsNullOrWhiteSpace(registrationInput.Prefix?.Trim()))+{+pushRegisterionEvent.PushLocation = registrationInput.Prefix.Trim();+}+else+{+var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);+if (department == null || string.IsNullOrWhiteSpace(department.Code))+return BadRequest();+pushRegisterionEvent.PushLocation = department.Code;+}
🧹 Nitpick comments (1)
Core/Resgrid.Model/PushUri.cs (1)

37-38:Constrain PushLocation length and ensure non-empty semantics are consistent.

Service-level checks now require a non-empty PushLocation. Persisted data should reflect that and be bounded. Add a MaxLength constraint (pick a safe upper bound for Novu/topic identifiers) and keep [Required] if nulls must be disallowed at the DB layer.

-[ProtoMember(9)]+[MaxLength(64)]+[ProtoMember(9)] public string PushLocation { get; set; }

Please confirm the correct maximum length (e.g., 32/64) based on provider constraints.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between0ea711e and5312ac7.

📒 Files selected for processing (3)
  • Core/Resgrid.Model/PushUri.cs (1 hunks)
  • Core/Resgrid.Services/PushService.cs (1 hunks)
  • Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.cs: Prefer functional patterns and immutable data where appropriate in C#
Use modern C# features appropriately
Use meaningful, descriptive names for types, methods, and parameters; avoid unclear abbreviations
Separate state from behavior (e.g., use records for state and place operations in separate static classes)
Prefer pure methods over methods with side effects
Use extension methods appropriately for domain-specific operations
Design for testability; avoid hidden dependencies inside methods and prefer explicit, pure functions
Minimize constructor injection; keep the number of injected dependencies small
Prefer composition with interfaces to extend behavior

Files:

  • Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs
  • Core/Resgrid.Services/PushService.cs
  • Core/Resgrid.Model/PushUri.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (csharp)

Comment on lines +38 to 39
if(pushUri==null||String.IsNullOrWhiteSpace(pushUri.DeviceId)||string.IsNullOrWhiteSpace(pushUri.PushLocation))
returnfalse;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Good guard; align style and mirror DeviceId check in RegisterUnit.

  • Minor: usestring.IsNullOrWhiteSpace consistently.
  • Important:RegisterUnit should also validateDeviceId.
-if (pushUri == null || String.IsNullOrWhiteSpace(pushUri.DeviceId) || string.IsNullOrWhiteSpace(pushUri.PushLocation))+if (pushUri == null || string.IsNullOrWhiteSpace(pushUri.DeviceId) || string.IsNullOrWhiteSpace(pushUri.PushLocation)) return false;

Also update RegisterUnit’s guard (outside this hunk) to includeDeviceId:

if(pushUri==null||!pushUri.UnitId.HasValue||string.IsNullOrWhiteSpace(pushUri.DeviceId)||string.IsNullOrWhiteSpace(pushUri.PushLocation))returnfalse;
🤖 Prompt for AI Agents
In Core/Resgrid.Services/PushService.cs around lines 38-39, change the guard touse the lowercase string.IsNullOrWhiteSpace for consistency and ensureRegisterUnit’s guard (elsewhere in the file) mirrors the same checks by adding aDeviceId validation; update RegisterUnit’s null/unit check to also verifyDeviceId is not null/whitespace in addition to UnitId and PushLocation so bothentrypoints validate DeviceId consistently.

Comment on lines +157 to +163
if(!string.IsNullOrWhiteSpace(registrationInput.Prefix))
push.PushLocation=registrationInput.Prefix;
else
{
vardepartment=await_departmentsService.GetDepartmentByIdAsync(DepartmentId,false);
push.PushLocation=department.Code;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid NRE and guarantee non-empty PushLocation; trim Prefix and validate department fallback.

If department is null (or Code empty) this throws, and PushService.Register rejects empty locations. Harden this block.

-if (!string.IsNullOrWhiteSpace(registrationInput.Prefix))-push.PushLocation = registrationInput.Prefix;-else-{-var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);-push.PushLocation = department.Code;-}+if (!string.IsNullOrWhiteSpace(registrationInput.Prefix?.Trim()))+{+push.PushLocation = registrationInput.Prefix.Trim();+}+else+{+var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);+if (department == null || string.IsNullOrWhiteSpace(department.Code))+return BadRequest();+push.PushLocation = department.Code;+}
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(!string.IsNullOrWhiteSpace(registrationInput.Prefix))
push.PushLocation=registrationInput.Prefix;
else
{
vardepartment=await_departmentsService.GetDepartmentByIdAsync(DepartmentId,false);
push.PushLocation=department.Code;
}
if(!string.IsNullOrWhiteSpace(registrationInput.Prefix?.Trim()))
{
push.PushLocation=registrationInput.Prefix.Trim();
}
else
{
vardepartment=await_departmentsService.GetDepartmentByIdAsync(DepartmentId,false);
if(department==null||string.IsNullOrWhiteSpace(department.Code))
returnBadRequest();
push.PushLocation=department.Code;
}
🤖 Prompt for AI Agents
In Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs around lines 157to 163, trim registrationInput.Prefix and only use it if not null/whitespace;otherwise await _departmentsService.GetDepartmentByIdAsync and verify thedepartment is not null and department.Code is not null/whitespace (use trimmedvalues). If neither provides a valid non-empty PushLocation, return a BadRequest(or appropriate error) instead of assigning an empty value soPushService.Register won’t be given an empty location.

@ucswift
Copy link
MemberAuthor

Approve

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

This PR is approved.

@ucswiftucswift merged commit8b3f079 intomasterAug 28, 2025
16 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

@github-actionsgithub-actions[bot]github-actions[bot] approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ucswift

[8]ページ先頭

©2009-2025 Movatter.jp