Fix push subscription retrieval

Updates the push subscription query to retrieve a provider string rather
than only its numeric internal ID.

Change-Id: I910173409e48e8b6a6739d3122165c40b0d52b7f
This commit is contained in:
Michael Holloway 2020-06-02 19:20:06 -04:00 committed by Mateus Santos
parent a145bd0cbe
commit a5bcc65504
3 changed files with 6 additions and 4 deletions

View file

@ -22,7 +22,7 @@ class Subscription {
*/
public static function newFromRow( object $row ) {
return new self(
$row->eps_provider,
$row->epp_name,
$row->eps_token,
new ConvertibleTimestamp( $row->eps_updated )
);

View file

@ -70,10 +70,12 @@ class SubscriptionManager extends EchoAbstractMapper {
*/
public function getSubscriptionsForUser( int $centralId ) {
$res = $this->dbr->select(
'echo_push_subscription',
[ 'echo_push_subscription', 'echo_push_provider' ],
'*',
[ 'eps_user' => $centralId ],
__METHOD__
__METHOD__,
[],
[ 'echo_push_provider' => [ 'INNER JOIN', [ 'eps_provider = epp_id' ] ] ]
);
$result = [];
foreach ( $res as $row ) {

View file

@ -9,7 +9,7 @@ class SubscriptionTest extends MediaWikiUnitTestCase {
public function testNewFromRow(): void {
$row = new stdClass();
$row->eps_token = 'ABC123';
$row->eps_provider = 'fcm';
$row->epp_name = 'fcm';
$row->eps_updated = '2020-01-01 10:10:10';
$subscription = Subscription::newFromRow( $row );