Ignore requests with no subscription data

This commit is contained in:
Josef Citrine 2016-06-14 00:40:14 +01:00
parent 6e87e330f3
commit 60f55e6223
2 changed files with 18 additions and 14 deletions

View file

@ -73,7 +73,7 @@ class NotificationsController extends ApiControllerBase
public function postSubscribe()
{
$input = json_decode(Input::json('subscription'));
if ($input != 'null') {
$existing = Subscription::where('endpoint', '=', $input->endpoint)
->where('user_id', '=', Auth::user()->id)
->first();
@ -90,6 +90,9 @@ class NotificationsController extends ApiControllerBase
} else {
return ['id' => $existing->id];
}
} else {
return ['error' => 'No data'];
}
}
/**

View file

@ -37,7 +37,8 @@ class NativeDriver extends AbstractDriver {
* @param Activity $activity
* @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') {
$apiKeys = array(
'GCM' => Config::get('ponyfm.gcm_key'),