|
|
|
@ -372,7 +372,7 @@ class DirectMessageController extends Controller
|
|
|
|
|
->exists();
|
|
|
|
|
|
|
|
|
|
if ($recipient->domain == null && $hidden == false && ! $nf) {
|
|
|
|
|
$notification = new Notification();
|
|
|
|
|
$notification = new Notification;
|
|
|
|
|
$notification->profile_id = $recipient->id;
|
|
|
|
|
$notification->actor_id = $profile->id;
|
|
|
|
|
$notification->action = 'dm';
|
|
|
|
@ -405,6 +405,8 @@ class DirectMessageController extends Controller
|
|
|
|
|
{
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'pid' => 'required',
|
|
|
|
|
'max_id' => 'sometimes|integer',
|
|
|
|
|
'min_id' => 'sometimes|integer',
|
|
|
|
|
]);
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
abort_if($user->has_roles && ! UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
|
|
|
|
@ -419,29 +421,33 @@ class DirectMessageController extends Controller
|
|
|
|
|
if ($min_id) {
|
|
|
|
|
$res = DirectMessage::select('*')
|
|
|
|
|
->where('id', '>', $min_id)
|
|
|
|
|
->where(function ($q) use ($pid, $uid) {
|
|
|
|
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
|
|
|
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
|
|
|
|
->where(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
|
|
|
|
})->orWhere(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
|
|
|
|
})
|
|
|
|
|
->latest()
|
|
|
|
|
->orderBy('id', 'asc')
|
|
|
|
|
->take(8)
|
|
|
|
|
->get();
|
|
|
|
|
->get()
|
|
|
|
|
->reverse();
|
|
|
|
|
} elseif ($max_id) {
|
|
|
|
|
$res = DirectMessage::select('*')
|
|
|
|
|
->where('id', '<', $max_id)
|
|
|
|
|
->where(function ($q) use ($pid, $uid) {
|
|
|
|
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
|
|
|
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
|
|
|
|
->where(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
|
|
|
|
})->orWhere(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
|
|
|
|
})
|
|
|
|
|
->latest()
|
|
|
|
|
->orderBy('id', 'desc')
|
|
|
|
|
->take(8)
|
|
|
|
|
->get();
|
|
|
|
|
} else {
|
|
|
|
|
$res = DirectMessage::where(function ($q) use ($pid, $uid) {
|
|
|
|
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
|
|
|
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
|
|
|
|
$res = DirectMessage::where(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
|
|
|
|
})->orWhere(function ($query) use ($pid, $uid) {
|
|
|
|
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
|
|
|
|
})
|
|
|
|
|
->latest()
|
|
|
|
|
->orderBy('id', 'desc')
|
|
|
|
|
->take(8)
|
|
|
|
|
->get();
|
|
|
|
|
}
|
|
|
|
@ -636,7 +642,7 @@ class DirectMessageController extends Controller
|
|
|
|
|
$status->in_reply_to_profile_id = $recipient->id;
|
|
|
|
|
$status->save();
|
|
|
|
|
|
|
|
|
|
$media = new Media();
|
|
|
|
|
$media = new Media;
|
|
|
|
|
$media->status_id = $status->id;
|
|
|
|
|
$media->profile_id = $profile->id;
|
|
|
|
|
$media->user_id = $user->id;
|
|
|
|
|