forked from mirror/pixelfed
commit
d8a169870e
|
@ -403,20 +403,28 @@ class StatusController extends Controller
|
|||
public function storeView(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'status_id' => 'required|integer|exists:statuses,id',
|
||||
'profile_id' => 'required|integer|exists:profiles,id'
|
||||
'_v' => 'required|array'
|
||||
]);
|
||||
|
||||
$sid = (int) $request->input('status_id');
|
||||
$pid = (int) $request->input('profile_id');
|
||||
$views = $request->input('_v');
|
||||
$uid = $request->user()->profile_id;
|
||||
|
||||
StatusView::firstOrCreate([
|
||||
'status_id' => $sid,
|
||||
'status_profile_id' => $pid,
|
||||
'profile_id' => $request->user()->profile_id
|
||||
]);
|
||||
if(empty($views)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($views as $view) {
|
||||
if(!isset($view['sid']) || !isset($view['pid'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StatusView::firstOrCreate([
|
||||
'status_id' => $view['sid'],
|
||||
'status_profile_id' => $view['pid'],
|
||||
'profile_id' => $uid
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json(1);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1076,13 +1076,14 @@
|
|||
if (res.data.length && this.loading == false) {
|
||||
let data = res.data;
|
||||
let self = this;
|
||||
let vids = [];
|
||||
data.forEach((d, index) => {
|
||||
if(self.ids.indexOf(d.id) == -1) {
|
||||
self.feed.push(d);
|
||||
self.ids.push(d.id);
|
||||
axios.post('/api/status/view', {
|
||||
'status_id': d.id,
|
||||
'profile_id': d.account.id
|
||||
vids.push({
|
||||
sid: d.id,
|
||||
pid: d.account.id
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1091,6 +1092,9 @@
|
|||
this.page += 1;
|
||||
$state.loaded();
|
||||
this.loading = false;
|
||||
axios.post('/api/status/view', {
|
||||
'_v': vids,
|
||||
});
|
||||
} else {
|
||||
$state.complete();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue