2016-12-09 11:53:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pony.fm - A community for pony fan music.
|
2018-04-21 06:25:36 +02:00
|
|
|
* Copyright (C) 2016 Feld0
|
2016-12-09 11:53:32 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Poniverse\Ponyfm\Http\Controllers;
|
|
|
|
|
2016-12-23 15:31:45 +01:00
|
|
|
use App;
|
2016-12-28 16:07:28 +01:00
|
|
|
use Auth;
|
2016-12-23 14:08:41 +01:00
|
|
|
use DB;
|
2016-12-09 11:53:32 +01:00
|
|
|
use Poniverse\Ponyfm\Models\Email;
|
|
|
|
use Poniverse\Ponyfm\Models\EmailSubscription;
|
2016-12-28 16:07:28 +01:00
|
|
|
use View;
|
2016-12-09 11:53:32 +01:00
|
|
|
|
2016-12-23 15:31:45 +01:00
|
|
|
|
2016-12-09 11:53:32 +01:00
|
|
|
class NotificationsController extends Controller {
|
2016-12-25 03:11:42 +01:00
|
|
|
/**
|
|
|
|
* @param $emailKey
|
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
|
|
|
*/
|
2016-12-09 11:53:32 +01:00
|
|
|
public function getEmailClick($emailKey) {
|
|
|
|
/** @var Email $email */
|
|
|
|
$email = Email::findOrFail($emailKey);
|
|
|
|
|
2016-12-23 14:08:41 +01:00
|
|
|
DB::transaction(function() use ($email) {
|
|
|
|
$email->emailClicks()->create(['ip_address' => \Request::ip()]);
|
|
|
|
$email->notification->is_read = true;
|
|
|
|
$email->notification->save();
|
|
|
|
});
|
2016-12-09 11:53:32 +01:00
|
|
|
|
|
|
|
return redirect($email->getActivity()->url);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmailUnsubscribe($subscriptionKey) {
|
2016-12-28 16:07:28 +01:00
|
|
|
/** @var EmailSubscription $subscription */
|
2016-12-25 03:11:42 +01:00
|
|
|
$subscription = EmailSubscription::findOrFail($subscriptionKey);
|
|
|
|
$subscription->delete();
|
2016-12-09 11:53:32 +01:00
|
|
|
|
2016-12-28 16:07:28 +01:00
|
|
|
if (Auth::check() && $subscription->user->id === Auth::user()->id) {
|
|
|
|
return redirect(route('account:settings', [
|
|
|
|
'slug' => $subscription->user->slug,
|
|
|
|
'unsubscribedMessageKey' => $subscription->activity_type
|
|
|
|
]), 303);
|
|
|
|
} else {
|
|
|
|
return redirect(route('email:confirm-unsubscribed', [
|
|
|
|
'unsubscribedUser' => $subscription->user->display_name,
|
|
|
|
'unsubscribedMessageKey' => $subscription->activity_type
|
|
|
|
]), 303);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmailUnsubscribePage() {
|
|
|
|
return View::make('shared.null');
|
2016-12-09 11:53:32 +01:00
|
|
|
}
|
|
|
|
}
|