mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-18 02:40:50 +00:00
a3674974f1
Adds DB tables for storing push subscriptions, some DB interaction code for retrieving them within MediaWiki, and a set of API modules for managing them from the outside world. When testing this patch, be sure to run maintenance/update.php to create the new tables, and set $wgEchoEnablePush = true in LocalSettings.php to enable the API new API module. N.B. The current DB schema is centered on app push subscriptions. Web push subscriptions require slightly different handling, since they are provided by browsers as a JSON blob rather than a token string. How to handle web push subscriptions is a question we can defer until the time comes to add web push support. Subscription data is stored in the echo_push_subscription table, with provider names normalized into the echo_push_provider table. We expect to be looking up subscriptions by central user ID, so that column is indexed. The subscription data also includes a column to store SHA256 digests of the subscriber tokens. This is for use as a unique key constraint, since we expect every push token to be univerally unique, and the token values themselves may be too large to reasonably index in MySQL. Bug: T252899 Change-Id: I3928761b3fba12e54ff4850e9a05c68ec7772f62
19 lines
819 B
SQL
19 lines
819 B
SQL
-- Stores push subscriptions associated with wiki users.
|
|
CREATE TABLE /*_*/echo_push_subscription (
|
|
eps_id INT UNSIGNED NOT NULL PRIMARY KEY auto_increment,
|
|
-- central user ID
|
|
eps_user INT UNSIGNED NOT NULL,
|
|
-- platform-provided push subscription token
|
|
eps_token TEXT NOT NULL,
|
|
-- SHA256 digest of the push subscription token (to be used as a uniqueness constraint, since
|
|
-- the tokens themselves may be large)
|
|
eps_token_sha256 CHAR(64) NOT NULL UNIQUE,
|
|
-- push provider ID, expected to reference values 'fcm' or 'apns'
|
|
eps_provider TINYINT UNSIGNED NOT NULL,
|
|
-- last updated timestamp
|
|
eps_updated TIMESTAMP NOT NULL,
|
|
FOREIGN KEY (eps_provider) REFERENCES /*_*/echo_push_provider(epp_id)
|
|
) /*$wgDBTableOptions*/;
|
|
|
|
CREATE INDEX /*i*/echo_push_subscription_user_id ON /*_*/echo_push_subscription (eps_user);
|