-
Notifications
You must be signed in to change notification settings - Fork 2
Home
He Yifei 何一非 edited this page Mar 22, 2019
·
1 revision
Welcome to the tsd-push-notification wiki!
CREATE TABLE wp_tsd_pn (
id bigint(20) NOT NULL AUTO_INCREMENT,
receiver_id bigint(20) unsigned NOT NULL,
item_type varchar(20) NOT NULL,
item_id bigint(20) unsigned NOT NULL,
PRIMARY KEY (id),
UNIQUE (receiver_id, item_type, item_id),
INDEX (receiver_id, item_type),
INDEX (item_type, item_id)
);
Suppose:
- For subscriber
1144875
:
"subscribing": {
"list": ["daily", "breaking", "weekly"],
"category_ids": [2429],
"author_ids": [239, 1002026],
"location_ids": [9, 10, 11]
}
- For subscriber
1144876
:
"subscribing": {
"list": ["breaking"],
"category_ids": [2429, 4408],
"author_ids": [239],
"location_ids": [3, 9]
}
Then,
mysql> SELECT * FROM wp_tsd_pn;
+-----+-------------+--------------+---------+
| id | receiver_id | item_type | item_id |
+-----+-------------+--------------+---------+
| 111 | 1144875 | author_ids | 239 |
| 112 | 1144875 | author_ids | 1002026 |
| 110 | 1144875 | category_ids | 2429 |
| 103 | 1144875 | list | 51671 |
| 101 | 1144875 | list | 51672 |
| 102 | 1144875 | list | 51673 |
| 88 | 1144875 | location_ids | 9 |
| 89 | 1144875 | location_ids | 10 |
| 90 | 1144875 | location_ids | 11 |
| 115 | 1144876 | author_ids | 239 |
| 113 | 1144876 | category_ids | 2429 |
| 114 | 1144876 | category_ids | 4408 |
| 104 | 1144876 | list | 51673 |
| 116 | 1144876 | location_ids | 3 |
| 98 | 1144876 | location_ids | 9 |
+-----+-------------+--------------+---------+
item_id
for:
-
item_type
=list
Custom taxonomytsd_push_msg_receiver_group
’sterm_id
. Note that the strings used insubscribing
(such as"breaking"
) are the custom taxonomy'sslug
. -
item_type
=category_ids
Category’sterm_id
. -
item_type
=author_ids
Author’sID
. -
item_type
=location_ids
Location’sid
defined bytsd_locations_plugin_get_locations()
.
When the “Publish” button of a normal post is clicked:
- Find all authors / (if possible) co-authors of the post
- Find the subscriber for each author
- Add these subscriber ids to
$notification_receiver_ids
- Find all categories of the post
- Find the subscriber for each category
- Add these subscriber ids to
$notification_receiver_ids
- Find all tags of the post
- Find all locations related to the tags
- Find the subscriber for each location
- Add these subscriber ids to
$notification_receiver_ids
- Send the notification
- Title: Post title
- Body: Plain text of post content before
<!--more-->
tag - Data:
[ "post_id" => $post_id ]
- To:
array_unique( $notification_receiver_ids );
When the “Publish” button of a tsd_push_msg
post is clicked:
- Find all
tsd_push_msg_receiver_group
s of the post- Add these subscriber ids to
$notification_receiver_ids
- Add these subscriber ids to
- Send the notification
- Title: Post title
- Body: Post excerpt
- Data: Custom fields which have keys starting with
tsd_pn_
. For example, having a custom field calledtsd_pn_post_id
will addpost_id
and its value to the data. - To:
array_unique( $notification_receiver_ids );