Skip to content

Conversation

@capcom6
Copy link
Member

@capcom6 capcom6 commented Aug 23, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new webhook event for incoming MMS messages. You can now subscribe to receive notifications when an MMS is received.
    • The event appears alongside existing event types in listings and selectors.
    • Existing integrations continue to work unchanged; opt in to this event to start receiving MMS notifications.

@codecov
Copy link

codecov bot commented Aug 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
smsgateway/domain_webhooks.go 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link

coderabbitai bot commented Aug 23, 2025

Walkthrough

Adds a new exported webhook event constant "mms:received", registers it in the internal event list, and includes it in the WebhookEventTypes() helper return. Validation logic remains unchanged.

Changes

Cohort / File(s) Summary
Webhook events constants and registry
smsgateway/domain_webhooks.go
Added WebhookEventMmsReceived ("mms:received") constant; appended to allEventTypes; updated WebhookEventTypes() to include the new event; no changes to IsValidWebhookEvent or Validate.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch client/add-mms-received-event

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 with CodeRabbit:

  • 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 @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai 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:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai 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 our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @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 the configuration 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 our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot 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: 0

🧹 Nitpick comments (3)
smsgateway/domain_webhooks.go (3)

27-49: Reduce duplication: derive map and slice from a single ordered list.

Right now we maintain the set (allEventTypes) and the slice (WebhookEventTypes) separately; this is easy to desync on future edits. Consider a single source of truth that preserves your preferred order.

Apply within this block:

-//nolint:gochecknoglobals // lookup table
-var allEventTypes = map[WebhookEvent]struct{}{
-	WebhookEventSmsReceived:     {},
-	WebhookEventSmsDataReceived: {},
-	WebhookEventSmsSent:         {},
-	WebhookEventSmsDelivered:    {},
-	WebhookEventSmsFailed:       {},
-	WebhookEventSystemPing:      {},
-	WebhookEventMmsReceived:     {},
-}
-
-// WebhookEventTypes returns a slice of all supported webhook event types.
-func WebhookEventTypes() []WebhookEvent {
-	return []WebhookEvent{
-		WebhookEventSmsReceived,
-		WebhookEventSmsDataReceived,
-		WebhookEventSmsSent,
-		WebhookEventSmsDelivered,
-		WebhookEventSmsFailed,
-		WebhookEventSystemPing,
-		WebhookEventMmsReceived,
-	}
-}
+// Keep a single ordered list and derive other structures from it.
+var webhookEventTypesOrdered = []WebhookEvent{
+	WebhookEventSmsReceived,
+	WebhookEventSmsDataReceived,
+	WebhookEventSmsSent,
+	WebhookEventSmsDelivered,
+	WebhookEventSmsFailed,
+	WebhookEventSystemPing,
+	WebhookEventMmsReceived,
+}
+
+//nolint:gochecknoglobals // lookup table derived from the ordered list
+var allEventTypes = func() map[WebhookEvent]struct{} {
+	m := make(map[WebhookEvent]struct{}, len(webhookEventTypesOrdered))
+	for _, e := range webhookEventTypesOrdered {
+		m[e] = struct{}{}
+	}
+	return m
+}()
+
+// WebhookEventTypes returns a copy of the ordered list of supported webhook event types.
+func WebhookEventTypes() []WebhookEvent {
+	out := make([]WebhookEvent, len(webhookEventTypesOrdered))
+	copy(out, webhookEventTypesOrdered)
+	return out
+}

72-72: Optional: update the example to showcase the new event.

This helps surface the feature in generated docs and examples.

Go snippet:

// The type of event the webhook is triggered for.
Event WebhookEvent `json:"event" validate:"required" example:"mms:received"`

23-24: Add/adjust tests to cover the new event.

Minimal additions to prevent regressions:

Go tests (new file suggestion: smsgateway/domain_webhooks_test.go):

package smsgateway

import "testing"

func TestIsValidWebhookEvent_MMSReceived(t *testing.T) {
	if !IsValidWebhookEvent(WebhookEventMmsReceived) {
		t.Fatalf("expected mms:received to be valid")
	}
}

func TestWebhook_Validate_MMSReceived(t *testing.T) {
	w := Webhook{
		ID:       "123e4567-e89b-12d3-a456-426614174000",
		DeviceID: nil,
		URL:      "https://example.com/webhook",
		Event:    WebhookEventMmsReceived,
	}
	if err := w.Validate(); err != nil {
		t.Fatalf("validate failed for mms:received: %v", err)
	}
}

If you’d like, I can push these tests as a follow-up.

📜 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 between 1b4ec68 and 9f44835.

📒 Files selected for processing (1)
  • smsgateway/domain_webhooks.go (3 hunks)
🔇 Additional comments (4)
smsgateway/domain_webhooks.go (4)

23-24: New event constant looks correct and consistent.

Naming, string value, and comment align with existing SMS event conventions.


35-35: Properly registered in the validation set.

Adding the new event to allEventTypes ensures IsValidWebhookEvent() and Validate() accept it.


47-47: Exposed via WebhookEventTypes().

Including the event in the helper keeps API consumers in sync.


23-24: Sanity check passed – no hardcoded event strings found outside domain_webhooks.go

  • domain_webhooks.go and its accompanying tests and lookup table now include WebhookEventMmsReceived.
  • No occurrences of sms:… or mms:received were found in markdown docs (*.md), an examples/ directory, or a docs/ folder.
  • No tests assume a specific ordering of WebhookEventTypes().

Everything appears in sync; no further updates to docs or samples are needed.

@capcom6 capcom6 merged commit f35dcbc into master Aug 23, 2025
7 checks passed
@capcom6 capcom6 deleted the client/add-mms-received-event branch August 23, 2025 13:38
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.

2 participants