mediawiki-extensions-Echo/includes/Push/Subscription.php
Mateus Santos c188dac23f push: send apns topic when present
1) send apns topic when present in subscription metadata
2) check if subscription metadata is a valid JSON string
3) make epp_id column at echo_push_provider table auto_increment,
otherwise it will fail when trying to add a second row in the table

Bug: T259394
Change-Id: I785435e9f2d4ba9c14977d431d271f0fa2d0c795
2020-08-18 13:21:20 +00:00

69 lines
1.4 KiB
PHP

<?php
namespace EchoPush;
use Wikimedia\Timestamp\ConvertibleTimestamp;
class Subscription {
/** @var string */
private $provider;
/** @var string */
private $token;
/** @var ConvertibleTimestamp */
private $updated;
/** @var string|null */
private $topic;
/**
* Construct a subscription from a DB result row.
* @param object $row echo_push_subscription row from IResultWrapper::fetchRow
* @return Subscription
*/
public static function newFromRow( object $row ) {
return new self(
$row->epp_name,
$row->eps_token,
$row->eps_topic,
new ConvertibleTimestamp( $row->eps_updated )
);
}
/**
* @param string $provider
* @param string $token
* @param string|null $topic
* @param ConvertibleTimestamp $updated
*/
public function __construct( string $provider, string $token, ?string $topic, ConvertibleTimestamp $updated ) {
$this->provider = $provider;
$this->token = $token;
$this->topic = $topic;
$this->updated = $updated;
}
/** @return string provider */
public function getProvider(): string {
return $this->provider;
}
/** @return string token */
public function getToken(): string {
return $this->token;
}
/** @return string|null topic */
public function getTopic(): ?string {
return $this->topic;
}
/** @return ConvertibleTimestamp last updated timestamp */
public function getUpdated(): ConvertibleTimestamp {
return $this->updated;
}
}