Add push notifications and device token management

This commit is contained in:
Ben Goldsworthy 2020-11-30 17:34:13 +00:00
parent 9d4c736d95
commit bb161dfd25
14 changed files with 5320 additions and 6 deletions

View file

@ -0,0 +1,44 @@
package Pear::LocalLoop::Schema::Result::DeviceSubscription;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table("device_subscriptions");
__PACKAGE__->add_columns(
"id" => {
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
},
"device_token_id" => {
data_type => "integer",
is_foreign_key => 1,
is_nullable => 0,
},
"topic_id" => {
data_type => "integer",
is_foreign_key => 1,
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
"device_token",
"Pear::LocalLoop::Schema::Result::DeviceToken",
"device_token_id",
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
__PACKAGE__->belongs_to(
"topic",
"Pear::LocalLoop::Schema::Result::Topic",
"topic_id",
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
1;

View file

@ -44,4 +44,13 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
__PACKAGE__->has_many(
"device_subscriptions",
"Pear::LocalLoop::Schema::Result::DeviceSubscription",
{ "foreign.device_token_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->many_to_many('topics' => 'device_subscriptions', 'topic');
1;

View file

@ -0,0 +1,40 @@
package Pear::LocalLoop::Schema::Result::Topic;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->load_components( qw/
InflateColumn::DateTime
TimeStamp
FilterColumn
/);
__PACKAGE__->table("topics");
__PACKAGE__->add_columns(
"id" => {
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
},
"name" => {
data_type => "varchar",
size => 200,
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
"device_subscriptions",
"Pear::LocalLoop::Schema::Result::DeviceSubscription",
{ "foreign.topic_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->many_to_many('device_tokens' => 'device_subscriptions', 'device_token');
1;