Skip to content

refactor: extract entitlement entity names to constants#895

Merged
AchoArnold merged 1 commit into
mainfrom
refactor/entitlement-entity-name-constants
May 17, 2026
Merged

refactor: extract entitlement entity names to constants#895
AchoArnold merged 1 commit into
mainfrom
refactor/entitlement-entity-name-constants

Conversation

@AchoArnold
Copy link
Copy Markdown
Member

Replace magic strings with exported constants: services.EntityNameMessageSendSchedule and services.EntityNamePhoneAPIKey. This makes it easier to add new entitlement-limited entities and avoids typo risks.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR extracts two repeated magic strings used in entitlement checks into exported package-level constants in entitlement_service.go, then replaces the inline literals in the two handler files with those constants. No runtime behavior changes.

  • entitlement_service.go: Declares EntityNameMessageSendSchedule and EntityNamePhoneAPIKey constants, then updates the entityLimits map keys to use them instead of inline strings.
  • message_send_schedule_handler.go / phone_api_key_handler.go: Each swaps one magic-string argument in the entitlementService.Check(...) call for the corresponding exported constant.

Confidence Score: 5/5

Pure rename refactor with no logic changes; the constant values are identical to the original magic strings, so runtime behaviour is unchanged.

Both constant values exactly match the strings they replace, the entityLimits map and both handler call sites are updated consistently, and no residual magic-string usages were found elsewhere in the codebase.

No files require special attention.

Important Files Changed

Filename Overview
api/pkg/services/entitlement_service.go Adds two exported string constants and updates entityLimits map keys to use them; no logic changes.
api/pkg/handlers/message_send_schedule_handler.go Replaces magic string with services.EntityNameMessageSendSchedule in the entitlement check call; functionally identical.
api/pkg/handlers/phone_api_key_handler.go Replaces magic string with services.EntityNamePhoneAPIKey in the entitlement check call; functionally identical.

Sequence Diagram

sequenceDiagram
    participant H as Handler (Store)
    participant E as EntitlementService.Check
    participant L as entityLimits map

    H->>E: Check(ctx, userID, EntityNameMessageSendSchedule / EntityNamePhoneAPIKey, countFunc)
    E->>L: lookup entityLimits[entityName]
    L-->>E: plan limits (or not found → unlimited)
    E-->>H: "EntitlementCheckResult{Allowed, Message}"
Loading

Reviews (1): Last reviewed commit: "refactor: extract entitlement entity nam..." | Re-trigger Greptile

@AchoArnold AchoArnold force-pushed the refactor/entitlement-entity-name-constants branch from 7d6c30e to 78135be Compare May 17, 2026 16:03
Move EntityNameMessageSendSchedule and EntityNamePhoneAPIKey constants
from the services package to their respective entity files in the
entities package, keeping them co-located with the types they describe.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@AchoArnold AchoArnold merged commit e114f5a into main May 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant