mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-26 06:57:58 +01:00
Ignore requests with no subscription data
This commit is contained in:
parent
6e87e330f3
commit
60f55e6223
2 changed files with 18 additions and 14 deletions
|
@ -73,22 +73,25 @@ class NotificationsController extends ApiControllerBase
|
||||||
public function postSubscribe()
|
public function postSubscribe()
|
||||||
{
|
{
|
||||||
$input = json_decode(Input::json('subscription'));
|
$input = json_decode(Input::json('subscription'));
|
||||||
|
if ($input != 'null') {
|
||||||
|
$existing = Subscription::where('endpoint', '=', $input->endpoint)
|
||||||
|
->where('user_id', '=', Auth::user()->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
$existing = Subscription::where('endpoint', '=', $input->endpoint)
|
if ($existing === null) {
|
||||||
->where('user_id', '=', Auth::user()->id)
|
$subscription = Subscription::create([
|
||||||
->first();
|
'user_id' => Auth::user()->id,
|
||||||
|
'endpoint' => $input->endpoint,
|
||||||
|
'p256dh' => $input->keys->p256dh,
|
||||||
|
'auth' => $input->keys->auth
|
||||||
|
]);
|
||||||
|
|
||||||
if ($existing === null) {
|
return ['id' => $subscription->id];
|
||||||
$subscription = Subscription::create([
|
} else {
|
||||||
'user_id' => Auth::user()->id,
|
return ['id' => $existing->id];
|
||||||
'endpoint' => $input->endpoint,
|
}
|
||||||
'p256dh' => $input->keys->p256dh,
|
|
||||||
'auth' => $input->keys->auth
|
|
||||||
]);
|
|
||||||
|
|
||||||
return ['id' => $subscription->id];
|
|
||||||
} else {
|
} else {
|
||||||
return ['id' => $existing->id];
|
return ['error' => 'No data'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ class NativeDriver extends AbstractDriver {
|
||||||
* @param Activity $activity
|
* @param Activity $activity
|
||||||
* @param User[] $recipients collection of {@link User} objects
|
* @param User[] $recipients collection of {@link User} objects
|
||||||
*/
|
*/
|
||||||
private function pushNotifications(Activity $activity, $recipients) {
|
private function pushNotifications(Activity $activity, $recipients)
|
||||||
|
{
|
||||||
if (Config::get('ponyfm.gcm_key') != 'default') {
|
if (Config::get('ponyfm.gcm_key') != 'default') {
|
||||||
$apiKeys = array(
|
$apiKeys = array(
|
||||||
'GCM' => Config::get('ponyfm.gcm_key'),
|
'GCM' => Config::get('ponyfm.gcm_key'),
|
||||||
|
|
Loading…
Reference in a new issue