Add channel creation, subscription
This commit is contained in:
parent
def0cbb93a
commit
5292540d1d
9 changed files with 109 additions and 40 deletions
|
@ -46,13 +46,4 @@ __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;
|
||||
|
|
|
@ -43,15 +43,17 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"device_subscriptions",
|
||||
"Pear::LocalLoop::Schema::Result::DeviceSubscription",
|
||||
"user_topic_subscriptions",
|
||||
"Pear::LocalLoop::Schema::Result::UserTopicSubscription",
|
||||
{ "foreign.topic_id" => "self.id" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
__PACKAGE__->many_to_many(
|
||||
'device_tokens' => 'device_subscriptions',
|
||||
'device_token'
|
||||
'users' => 'user_topic_subscriptions',
|
||||
'user'
|
||||
);
|
||||
|
||||
__PACKAGE__->many_to_many( 'topics' => 'user_topic_subscriptions', 'topic' );
|
||||
|
||||
1;
|
||||
|
|
|
@ -84,6 +84,14 @@ __PACKAGE__->has_many(
|
|||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"user_topic_subscriptions",
|
||||
"Pear::LocalLoop::Schema::Result::UserTopicSubscription",
|
||||
{ "foreign.user_id" => "self.id" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
|
||||
__PACKAGE__->filter_column(
|
||||
is_admin => {
|
||||
filter_to_storage => 'to_bool',
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package Pear::LocalLoop::Schema::Result::DeviceSubscription;
|
||||
package Pear::LocalLoop::Schema::Result::UserTopicSubscription;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table("device_subscriptions");
|
||||
__PACKAGE__->table("user_topic_subscriptions");
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"id" => {
|
||||
|
@ -13,7 +13,7 @@ __PACKAGE__->add_columns(
|
|||
is_auto_increment => 1,
|
||||
is_nullable => 0,
|
||||
},
|
||||
"device_token_id" => {
|
||||
"user_id" => {
|
||||
data_type => "integer",
|
||||
is_foreign_key => 1,
|
||||
is_nullable => 0,
|
||||
|
@ -28,9 +28,9 @@ __PACKAGE__->add_columns(
|
|||
__PACKAGE__->set_primary_key("id");
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"device_token",
|
||||
"Pear::LocalLoop::Schema::Result::DeviceToken",
|
||||
"device_token_id",
|
||||
"user",
|
||||
"Pear::LocalLoop::Schema::Result::User",
|
||||
"user_id",
|
||||
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
||||
);
|
||||
|
Reference in a new issue