This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ragnaranks-29 Server language support database + vue * ragnaranks-29 Server language support database + vue * ragnaranks-29 Server language support database + vue * Apply fixes from StyleCI (#101) [ci skip] [skip ci] * account design improv * merge master * Apply fixes from StyleCI (#104) [ci skip] [skip ci] * #29, flags now seed correctly, flag images added, flags now show on homepage. * #29, tests * #42 Installation and quick test * Apply fixes from StyleCI (#105) [ci skip] [skip ci] * #42 Review reported controller, test and request * #42 Reports controller with view, required design for reported content * Apply fixes from StyleCI (#107) [ci skip] [skip ci] * #42 Design and modal actions * #42 Moderator tool actions are now tested and notifications are sent too the reporter. * Renamed reports controller to report controller * Apply fixes from StyleCI (#108) [ci skip] [skip ci] * Corrected Url * Reports can now be concluded, Concluded reports are not shown on moderation tools. * Update production files. * Apply fixes from StyleCI (#109) [ci skip] [skip ci]
- Loading branch information
Showing
30 changed files
with
587 additions
and
124,169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Report; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\JsonResponse; | ||
use App\Notifications\ReportedReviewAllowed; | ||
use App\Notifications\ReportedReviewRemoved; | ||
|
||
class ReportController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
return view('account.moderation', ['reports' => Report::unjudged()->latest()->with(['reporter', 'reportable'])->get()]); | ||
} | ||
|
||
public function update(Request $request, Report $report) : JsonResponse | ||
{ | ||
$report->reporter->notify(new ReportedReviewAllowed($report)); | ||
|
||
$report->conclude(['conclusion' => 'The report content was kept.', 'action_taken' => 'updated'], auth()->user()); | ||
|
||
return response()->json([], 200); | ||
} | ||
|
||
public function destroy(Report $report) | ||
{ | ||
$report->reportable->delete(); | ||
|
||
$report->conclude(['conclusion' => 'The reported content was removed.', 'action_taken' => 'deleted'], auth()->user()); | ||
|
||
$report->reporter->notify(new ReportedReviewRemoved($report)); | ||
|
||
return response()->json([], 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Interactions\Review; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\JsonResponse; | ||
use App\Http\Requests\ReviewReportRequest; | ||
|
||
class ReviewReportController extends Controller | ||
{ | ||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param Review $review | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function store(Review $review, ReviewReportRequest $request): JsonResponse | ||
{ | ||
$review = $review->report($request->validated(), auth()->user()); | ||
|
||
$status = $review->save(); | ||
|
||
return response()->json(['status' => $status], 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class ReviewReportRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'reason' => 'required', 'string', 'max:255', | ||
'meta' => 'sometimes', 'array', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Report; | ||
use App\Interactions\Review; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class ReportedReviewAllowed extends Notification | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* @var Review | ||
*/ | ||
private $report; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* @param Report $report | ||
*/ | ||
public function __construct(Report $report) | ||
{ | ||
$this->report = $report; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['database']; | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
'title' => 'Action taken on a review you reported!', | ||
'message' => "The review you reported {$this->report->created_at->diffForHumans()} was deemed acceptable by the moderation team", | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Report; | ||
use App\Interactions\Review; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class ReportedReviewRemoved extends Notification | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* @var Report | ||
*/ | ||
private $report; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @param Report $report | ||
*/ | ||
public function __construct(Report $report) | ||
{ | ||
$this->report = $report; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['database']; | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
'title' => 'Action taken on a review you reported!', | ||
'message' => "The review you reported {$this->report->created_at->diffForHumans()} broke our rules and was removed.", | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Relations\HasOne; | ||
use Illuminate\Database\Eloquent\Relations\MorphOne; | ||
|
||
/** | ||
* @property User reporter | ||
* @property MorphOne reportable | ||
*/ | ||
class Report extends \BrianFaust\Reportable\Models\Report | ||
{ | ||
public function scopeUnjudged(Builder $query) : Builder | ||
{ | ||
return $query->doesntHave('conclusion'); | ||
} | ||
|
||
/** | ||
* A report has a reporter. | ||
* | ||
* @return HasOne | ||
*/ | ||
public function reporter(): HasOne | ||
{ | ||
return $this->hasOne(User::class, 'id', 'reporter_id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.