Skip to content

通知ドメイン/ディスパッチ/APIコンバータにFCMオプションを追加#17

Merged
kantacky merged 13 commits into
mainfrom
feat/notification-fcm-options
Apr 24, 2026
Merged

通知ドメイン/ディスパッチ/APIコンバータにFCMオプションを追加#17
kantacky merged 13 commits into
mainfrom
feat/notification-fcm-options

Conversation

@kantacky
Copy link
Copy Markdown
Member

@kantacky kantacky commented Apr 22, 2026

概要

通知(Notification)ドメインに Firebase Cloud Messaging で設定可能な追加オプションを持たせ、ディスパッチ時の MulticastMessage と API コンバータの双方でそれらを扱えるようにした。

ベースブランチは update-openapi-schema で、OpenAPI スキーマ側への追加フィールド定義はそちらで対応済み。

変更点

モデル層

  • domain.Notification / database.Notification に以下のフィールドを追加した(いずれも optional)。
    • ImageURL — 通知画像
    • AnalyticsLabel — Firebase Analytics ラベル
    • APNsBadge / APNsSound / APNsContentAvailable — iOS 向け
    • AndroidChannelID / AndroidPriority / AndroidTTLSeconds — Android 向け
    • WebpushLink — Web Push クリック時リンク
  • GORM 側は text / integer / boolean の NULL 許容カラムとして定義した。
  • 本文フィールドを Message から Body に改称し、FCM SDK の Notification.Body に揃えた。

ディスパッチ層

  • service.sendToTokens で追加フィールドを MulticastMessage に反映するようにした。
    • Notification.ImageURL / FCMOptions.AnalyticsLabel
    • APNSConfig.Payload.ApsBadge / Sound / ContentAvailable
    • AndroidConfigNotification.ChannelID / Priority / TTL
    • WebpushConfig.FCMOptions.Link
  • 各プラットフォーム設定は該当フィールドがすべて nil のときは付与しないよう buildAndroidConfig / buildAPNSConfig / buildWebpushConfig に切り出して局所化した。

ハンドラ層

  • handler/converter.gotoAPINotification / toDomainNotification を拡張し、追加した FCM オプションをドメイン ⇔ API 型で相互変換するようにした。
  • APNsBadge / AndroidTTLSeconds はドメイン側の int と API 側の int32 の差異を明示的に変換する。

補足

  • 既存フィールド(Title / Body / URL など)のみで送信する既存挙動は変わらない。

動作確認

  • `go build ./...` が通る
  • 既存のディスパッチフローが、追加フィールド未指定の通知に対して従来どおり送信される
  • 追加フィールドを指定した通知が FCM に期待どおりのペイロードで届く

kantacky and others added 2 commits April 22, 2026 18:55
ImageURL/AnalyticsLabel/APNs(Badge/Sound/ContentAvailable)/Android(ChannelID/Priority/TTLSeconds)/WebpushLinkをドメインとGORMモデルに追加し、FCM送信で扱える追加設定を保持できるようにした。
あわせて本文フィールドをMessageからBodyへ改称し、FCM SDKのNotification.Body命名と揃えた。APIスキーマは後続対応のため変更せず、ハンドラのコンバータ側でBodyとMessageのマッピングを維持している。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ドメインに追加したFCMオプション群(ImageURL/AnalyticsLabel/APNs/Android/Webpush)を、MulticastMessageのNotification.ImageURL・FCMOptions・APNSConfig・AndroidConfig・WebpushConfigへそれぞれ設定するようにした。
各プラットフォーム設定は該当フィールドが全てnilのときは付与せず、部分指定でもそのまま送信できるようbuildAndroidConfig/buildAPNSConfig/buildWebpushConfigで組み立てを局所化している。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kantacky kantacky self-assigned this Apr 22, 2026
@kantacky kantacky changed the base branch from main to update-openapi-schema April 24, 2026 11:43
Notification のドメインモデルとAPI型に追加されていた
ImageURL / AnalyticsLabel / APNs・Android の配信オプション /
WebpushLink などのフィールドが、Converter で取りこぼされていた。
toAPINotification と toDomainNotification の双方で
これらのフィールドを相互に変換するようにし、
APNsBadge と AndroidTTLSeconds については
ドメイン側の int とAPI側の int32 の差異を明示的に変換する。
@kantacky kantacky marked this pull request as ready for review April 24, 2026 11:46
Copilot AI review requested due to automatic review settings April 24, 2026 11:46
@kantacky kantacky changed the title 通知ドメインにFCMオプションを追加しディスパッチに反映 通知ドメイン/ディスパッチ/APIコンバータにFCMオプションを追加 Apr 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

通知(Notification)ドメインに FCM の追加オプション(画像、AnalyticsLabel、APNs/Android/Webpush 設定)を保持できるようにし、ディスパッチ時に FCM の MulticastMessage へ反映するための変更です。

Changes:

  • 通知ドメイン/DBモデルに FCM 追加オプション用の optional フィールドを追加し、本文フィールドを MessageBody に改称
  • ディスパッチ処理でプラットフォーム別設定(Android/APNs/Webpush/FCMOptions)を組み立てて MulticastMessage に付与
  • API <-> domain 変換で新規オプション群をマッピング(badge/ttl は型変換を追加)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
internal/service/notification_dispatch.go 追加オプションを MulticastMessage に反映し、Android/APNs/Webpush 設定の組み立てを関数分離
internal/handler/converter.go Notification の新規オプション群を API/domain 間で相互変換(badge/ttl は int32 変換)
internal/domain/notification.go Notification ドメインに追加オプションフィールドを追加し本文を Body に統一
internal/database/notification.go Notification DBモデルに追加オプションカラムを追加し本文カラムを Body に改称

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/database/notification.go
Comment thread internal/handler/converter.go Outdated
Comment thread internal/handler/converter.go Outdated
Comment thread internal/handler/converter.go Outdated
github-actions Bot and others added 4 commits April 24, 2026 12:09
androidTtlSeconds と apnsBadge の型が int32 から int に変更されたため、生成コードを再生成した。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
APIとドメイン双方で APNsBadge / AndroidTTLSeconds が *int に統一されたため、
不要な int/int32 変換と nil 分岐を削除し、構造体リテラル内で直接代入する形に整理した。
振る舞いは変わらず、ビルド不整合の解消とコードの簡素化のみを行う。
Base automatically changed from update-openapi-schema to main April 24, 2026 12:42
@masaya-osuga masaya-osuga requested review from a team, hikaru-0602 and masaya-osuga April 24, 2026 12:42
@kantacky
Copy link
Copy Markdown
Member Author

コンフリクト修正します...

@kantacky
Copy link
Copy Markdown
Member Author

コンフリクト修正します...

修正した

@kantacky kantacky enabled auto-merge (squash) April 24, 2026 12:48
@kantacky kantacky merged commit b00b92e into main Apr 24, 2026
1 check passed
@kantacky kantacky deleted the feat/notification-fcm-options branch April 24, 2026 12:48
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.

3 participants