feat: add persistent mobile notifications
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Enums\FollowStatus;
|
||||
use App\Http\Requests\FollowRequest;
|
||||
use App\Http\Resources\FollowResource;
|
||||
use App\Models\User;
|
||||
use App\Notifications\NewFollowerNotification;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
@@ -27,7 +28,14 @@ class FollowController extends Controller
|
||||
// Default to Accepted as is_private doesn't exist in the DB yet
|
||||
$status = FollowStatus::Accepted;
|
||||
|
||||
$authUser->following()->syncWithPivotValues([$user->id], ['status' => $status], false);
|
||||
$changes = $authUser->following()->syncWithPivotValues([$user->id], ['status' => $status], false);
|
||||
|
||||
if ($changes['attached'] !== []) {
|
||||
$user->notify(
|
||||
(new NewFollowerNotification($authUser))
|
||||
->locale($user->preferredLocale()),
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => __('api.follows.followed'),
|
||||
|
||||
Reference in New Issue
Block a user