Commit graph

10 commits

Author SHA1 Message Date
James D. Forrester 4dd2a651e1 phpcs: Auto-fix MediaWiki.Usage.StaticClosure.StaticClosure
Change-Id: I6a02902ffaa8a9b497d60b573a0b8e3dbc207ee5
2021-05-04 09:06:42 -07:00
libraryupgrader b3f948c59c build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I4b2fb7f46b6c0a5c33a6ad25f085de8ae13eb084
2021-05-04 09:05:15 -07:00
Jeena Huneidi 008ad5afe1 Remove deprecated User method getGroups
Replaces the deprecated user method getGroups with
UserGroupManager->getUserGroups.

Bug: T275148
Change-Id: Ie6215886c911382008b667e8e5b3298facfcd6a2
2021-02-26 21:47:58 -08:00
Jeena Huneidi 596729d852 Make AttributeManager a service
Adds AttributeManager to EchoServices so that dependencies of
AttributeManager can be injected.

Bug: T275148
Change-Id: I4fa5084d72914d16b6d218e7dd3521f5a1919b80
2021-02-26 12:58:23 -08:00
jgiannelos 4abfbd3c96 Normalize eps_topic
* DB changes
 - Create a table for push topics NameTableStore
 - Add a foreign key on subscriptions to normalize push topics

* Implement NameTableStore to normalize topics
* Update DB query joins to include topic from foreignkey
* Adapt code to use IDs instead of the actual topic

Bug: T261756
Change-Id: Ia7589f4a607993352d45b2dd3bcb3867d12d6e97
2020-09-14 15:52:23 -04:00
Michael Holloway 3513c642dd Create push subscription manager group/right to clean up dead subs
Creates a new push-subscription-manager group and an associated
right, manage-all-push-subscriptions. The purpose of this is to
allow privileged accounts to purge expired subscriptions from the
database on behalf of other users. A user with this right will be
permitted to delete any subscription from the DB based on the token
alone. For all other users, deletion requests will be limited to
those associated with the requesting user's central ID.

This right will be granted to a bot account on Metawiki associated
with the Wikimedia push notifications service, and the push
notifications service account will make push subscription delete
requests to the API for subscriptions for which vendor APIs return bad
subscription responses.

Additionally, the providertoken parameter to ApiPushSubscriptionDelete
is updated to allow multiple providertoken values.

Bug: T259148
Change-Id: Ia6c17588ee94e6be74e5e3a75eb33e38f172fc93
2020-08-20 17:08:48 -04:00
Michael Holloway 15d48278be Create and enforce a config setting for max subscriptions per user
Creates a EchoPushMaxSubscriptionsPerUser config setting (default: 0)
that controls the maximum number of subscriptions a user may associate
with the user's central user ID.

The setting is enforced in EchoPush\SubscriptionManager::create().

To allow creating push subscriptions for development, set
$wgEchoPushMaxSubscriptionsPerUser to a positive integer value in
LocalSettings.php:

 $wgEchoPushMaxSubscriptionsPerUser = 10;

Bug: T259150
Change-Id: Ib97b6b6cbb8161dd75dad92c54b4fe4fff80c421
2020-08-12 17:58:11 -04:00
Michael Holloway 1d31fd753a Push: Submit requests to configured service endpoint
Finishes the implementation of the stubbed NotificationServiceClient.
Sends push notification request messages to the endpoint configured in
the EchoPushServiceBaseUrl setting. For example, to send messages to an
instance of mediawiki/services/push-notifications running on the host
machine while running MediaWiki in Docker, add the following line to
LocalSettings.php:

 $wgEchoPushServiceBaseUrl = 'http://172.17.0.1:8900/v1/message';

Bug: T252899
Change-Id: Icab7825e9080d6b1a4cfc5e12fed1da221ce4610
2020-06-08 13:37:24 +00:00
Michael Holloway ce7a46f7ed Add push notifier
Provides a basic push notifier implementation. Since the push service is
not yet in place, all it does for now is log debug output when a
notification is to be sent.

To register the push notifier, add the following configuration to
LocalSettings.php:

 $wgEchoNotifiers['push'] = [ 'EchoPush\\PushNotifier', 'notifyWithPush' ];
 $wgDefaultNotifyTypeAvailability['push'] = true;
 $wgNotifyTypeAvailabilityByCategory['system']['push'] = false;
 $wgNotifyTypeAvailabilityByCategory['system-noemail']['push'] = false;

We'll register the notifier in configuration for now, rather than
hard-coding the default in extension.json, in order to have control over
when and where it rolls out (beta vs. prod, as well as which wikis).

Since the push notifier implementation depends on jobs being processed
by the job queue, I also recommend adding the following configuration
setting to ensure that all pending jobs are processed at the end of each
web request:

 // ensure all pending jobs are processed when a web request completes
 $wgJobRunRate = PHP_INT_MAX;

Bug: T252899
Change-Id: Ie7f222443045d30620ff297b006104ef18a074a8
2020-06-02 13:40:04 -04:00
Michael Holloway a3674974f1 Add push subscription management
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
2020-06-02 13:40:00 -04:00