Skip to content

[webhooks] add device id field#22

Merged
capcom6 merged 1 commit intomasterfrom
webhooks/device-field
May 16, 2025
Merged

[webhooks] add device id field#22
capcom6 merged 1 commit intomasterfrom
webhooks/device-field

Conversation

@capcom6
Copy link
Copy Markdown
Member

@capcom6 capcom6 commented May 16, 2025

Summary by CodeRabbit

  • New Features
    • Added support for an optional device ID field when configuring webhooks. This allows users to associate a unique device identifier with each webhook.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2025

## Walkthrough

A new optional field, `DeviceID` (pointer to string), was added to the `Webhook` struct in the codebase. This field includes JSON serialization and validation tags, allowing webhooks to optionally specify an associated device identifier. Corresponding test cases were updated to include the `deviceId` field with null values in JSON requests and responses. No additional logic or validation changes were introduced.

## Changes

| File(s)                          | Change Summary                                                                                                              |
|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| smsgateway/domain_webhooks.go   | Added optional `DeviceID *string` field to the `Webhook` struct with JSON and validation metadata.                          |
| smsgateway/client_test.go        | Updated test server JSON payloads in webhook-related tests to include `"deviceId":null` in requests and responses; added error logging for request body mismatches. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant Webhook
    participant Device

    Client->>Webhook: Create/Update Webhook (with optional deviceId)
    Webhook-->>Device: Associates deviceId if provided
    Webhook-->>Client: Responds with webhook details (including deviceId if set)

<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 golangci-lint (1.64.8)</summary>
> 
> Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
> Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
> 
> 
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5876d8deb3558f7467879f5d28c837b5a90268f9 and 25bc23a8fecc74be6f9f933b0c1fc8377c499bc7.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `smsgateway/client_test.go` (2 hunks)
* `smsgateway/domain_webhooks.go` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary>

* smsgateway/domain_webhooks.go
* smsgateway/client_test.go

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4BtAO4kBsfPgDWiALrpa9JRPgMJCj0AGbwJBa0BgBy2MwClFwATEkGAKqIiYxo3EzMAGxG+sbgUGT0+CE4BMRkyjT0eWwYnDx8giJiktKQcgpKVKrqWjrFJlBwqKiY1YSk5FQNCqzsXFR2kIhxzGgU8n1MAypqmtq6YIYlpgaIzIhE1CR2aLIA9LQs2hgA+g5OLu4NER8BwDAAiCEGADEUMgAEEAJK1BaPehbVi7eSVRiwTCkRBGOGQcgbfDccT4DBoCyQMIRegAAwAIiR/IEEUyGfwqrhZNwgtx8PAWpRIARNrgKMKiJAABQMgBUiEl0oZAEpIM9kGgfHQxfgxbAggyAOqOZxuLnKijYMQaGAIZB0yKQCgkXjSdjIXBGyDYDDwACO2CC8CULXgdPaPN9fgCQTQiEQ+AY8FRmvUsENQT+Ftc9oRuBQGAYFmwSmQACkAMoAeWim0oaYs8AAXtR4JTIGxcDrqGg5QyhMmMBwwXH2bQwer0Bh6BJqWGO13e0RkPKFy3aI8xyx1CRmOTZAAaHYADwAvEkAIzTjV2TOzyAkM9oQ9WSCbkP26IG/A+0ULHwIgAn4PhNyXCksAYXEMHxTVKCCHYlH1dAGCaRRHkNVASVpcJIg0IwjBheELBoRZOwwb0DQAyAlFLXZ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- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=android-sms-gateway/client-go&utm_content=22):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- 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 src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Copy link
Copy Markdown

@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 (1)
smsgateway/client_test.go (1)

247-251: Added proper request validation with improved error reporting

The test now correctly expects the deviceId field in the JSON request and provides better error reporting when the request body doesn't match expectations.

Consider adding an explicit assertion for the DeviceID field in the test's "want" section (around line 286-290), even though it's null, to make the test more complete.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1e29d6 and 5876d8d.

📒 Files selected for processing (1)
  • smsgateway/client_test.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
smsgateway/client_test.go (2)

185-185: JSON response correctly includes the new deviceId field

The webhook list response now includes the deviceId field (set to null), which aligns with the addition of the new optional DeviceID field to the Webhook struct.


255-255: JSON response correctly includes the new deviceId field

The webhook registration response now includes the deviceId field (set to null), consistent with the Webhook struct update.

@capcom6 capcom6 force-pushed the webhooks/device-field branch from 5876d8d to 25bc23a Compare May 16, 2025 07:01
@capcom6 capcom6 merged commit b8b2f91 into master May 16, 2025
6 checks passed
@capcom6 capcom6 deleted the webhooks/device-field branch May 16, 2025 12:50
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