Skip to content

Bridge Device to ApplicationPushDevice#60

Merged
dadachi merged 1 commit intomainfrom
bridge-device-to-application-push-device
May 10, 2026
Merged

Bridge Device to ApplicationPushDevice#60
dadachi merged 1 commit intomainfrom
bridge-device-to-application-push-device

Conversation

@dadachi
Copy link
Copy Markdown
Contributor

@dadachi dadachi commented May 10, 2026

Summary

Closes the gap noted in #59: tokens registered via POST /api/v1/shopkeeper/devices now flow into ApplicationPushDevice, so ItemTagNotifier's deliver_by :action_push_native actually has devices to push to.

  • Drop the standalone Device model added in Add push notifications scaffolding via noticed v2 #59. Drop the devices table.
  • Rebuild action_push_native_devices with UUID primary key + UUID polymorphic owner + bundle_id / last_active_at columns + unique (platform, token) index (the gem's default migration uses bigint and a barebones schema).
  • Move validations / active scope / last_active_at touching from Device onto ApplicationPushDevice.
  • Shopkeeper has_many :application_push_devices, as: :owner replaces has_many :devices.
  • Renames: Api::Shopkeeper::DevicePolicyApi::Shopkeeper::ApplicationPushDevicePolicy; DeviceSerializerApplicationPushDeviceSerializer (JSONAPI type stays device via set_type :device). DevicesController route + path unchanged.

API contract change

device.platform enum is now [apple, google] (matches Action Push Native's APNs/FCM service convention) instead of [ios, android]. Done now because the mobile substrate clients haven't been built yet — PRs #3-5 (iOS/Android registration clients) will register with apple or google. Avoids needing a translation layer in the model just to fight the gem's enum.

Test plan

  • bin/rubocop — 243 files, 0 offenses
  • bin/brakeman — 0 warnings
  • bin/rails test — 419 runs, 870 assertions, 0 failures
  • Migration up + down both work locally

🤖 Generated with Claude Code

Drop the standalone Device model and consolidate push-token
registration onto ApplicationPushDevice (subclass of
ActionPushNative::Device) so deliver_by :action_push_native actually
fires for tokens registered via POST /api/v1/shopkeeper/devices.

- Drop devices table; rebuild action_push_native_devices with UUID
  primary key + UUID polymorphic owner + bundle_id / last_active_at
  columns + unique (platform, token) index
- Move validations / active scope / last_active_at touching from
  Device onto ApplicationPushDevice
- Shopkeeper has_many :application_push_devices, as: :owner
- DevicesController now manages ApplicationPushDevice; JSONAPI type
  stays "device" via set_type :device on the new serializer
- API contract change (pre-mobile-client): device.platform enum is
  now [apple, google] (matches Action Push Native's APNs/FCM
  convention). PRs #3-5 (iOS/Android substrate clients) will
  register with apple or google.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dadachi dadachi merged commit 88e1e4d into main May 10, 2026
3 checks passed
@dadachi dadachi deleted the bridge-device-to-application-push-device branch May 10, 2026 05:26
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