mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 22:50:45 +00:00
commit
67f7a75bd0
16 changed files with 472 additions and 453 deletions
|
@ -76,6 +76,12 @@
|
||||||
- Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2))
|
- Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2))
|
||||||
- Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c))
|
- Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c))
|
||||||
- Updated StatusController, allow license edits without 24 hour limit. ([c799a01a](https://github.com/pixelfed/pixelfed/commit/c799a01a))
|
- Updated StatusController, allow license edits without 24 hour limit. ([c799a01a](https://github.com/pixelfed/pixelfed/commit/c799a01a))
|
||||||
|
- Updated Settings, remove reports page. ([9cf962ff](https://github.com/pixelfed/pixelfed/commit/9cf962ff))
|
||||||
|
- Updated ProfileService, use account transformer. ([391b1287](https://github.com/pixelfed/pixelfed/commit/391b1287))
|
||||||
|
- Updated LikeController, hide like counts. ([ea687240](https://github.com/pixelfed/pixelfed/commit/ea687240))
|
||||||
|
- Updated StatusTransformers, add liked_by attribute. ([372bacb0](https://github.com/pixelfed/pixelfed/commit/372bacb0))
|
||||||
|
- Updated PostComponent, change like logic. ([0a35f5d6](https://github.com/pixelfed/pixelfed/commit/0a35f5d6))
|
||||||
|
- Updated Timeline component, change like logic. ([7bcbf96b](https://github.com/pixelfed/pixelfed/commit/7bcbf96b))
|
||||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
||||||
|
|
|
@ -62,7 +62,7 @@ class LikeController extends Controller
|
||||||
StatusService::del($status->id);
|
StatusService::del($status->id);
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count];
|
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => 0];
|
||||||
} else {
|
} else {
|
||||||
$response = redirect($status->url());
|
$response = redirect($status->url());
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,13 +151,6 @@ class SettingsController extends Controller
|
||||||
return view('settings.export.show');
|
return view('settings.export.show');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reportsHome(Request $request)
|
|
||||||
{
|
|
||||||
$profile = Auth::user()->profile;
|
|
||||||
$reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10);
|
|
||||||
return view('settings.reports', compact('reports'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function metroDarkMode(Request $request)
|
public function metroDarkMode(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
|
|
65
app/Services/LikeService.php
Normal file
65
app/Services/LikeService.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Util\ActivityPub\Helpers;
|
||||||
|
use Illuminate\Support\Facades\Redis;
|
||||||
|
use App\Like;
|
||||||
|
|
||||||
|
class LikeService {
|
||||||
|
|
||||||
|
const CACHE_KEY = 'pf:services:likes:ids:';
|
||||||
|
|
||||||
|
public static function getUser($profile_id)
|
||||||
|
{
|
||||||
|
return self::get($profile_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function get($profile_id)
|
||||||
|
{
|
||||||
|
$key = self::CACHE_KEY . $profile_id;
|
||||||
|
if(Redis::zcard($key) == 0) {
|
||||||
|
self::warmCache($profile_id);
|
||||||
|
} else {
|
||||||
|
return Redis::zrevrange($key, 0, 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function set($profile_id, $status_id)
|
||||||
|
{
|
||||||
|
$key = self::CACHE_KEY . $profile_id;
|
||||||
|
Redis::zadd($key, $status_id, $status_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function warmCache($profile_id)
|
||||||
|
{
|
||||||
|
Like::select('id', 'profile_id', 'status_id')
|
||||||
|
->whereProfileId($profile_id)
|
||||||
|
->latest()
|
||||||
|
->get()
|
||||||
|
->each(function($like) use ($profile_id) {
|
||||||
|
self::set($profile_id, $like->status_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function liked($profileId, $statusId)
|
||||||
|
{
|
||||||
|
$key = self::CACHE_KEY . $profileId;
|
||||||
|
return (bool) Redis::zrank($key, $statusId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function likedBy($status)
|
||||||
|
{
|
||||||
|
if(!$status->likes_count) {
|
||||||
|
return [
|
||||||
|
'username' => null,
|
||||||
|
'others' => false
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$id = Like::whereStatusId($status->id)->first()->profile_id;
|
||||||
|
return [
|
||||||
|
'username' => ProfileService::get($id)['username'],
|
||||||
|
'others' => $status->likes_count >= 5,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ class MediaTagService
|
||||||
|
|
||||||
protected function idToUsername($id)
|
protected function idToUsername($id)
|
||||||
{
|
{
|
||||||
$profile = ProfileService::build()->profileId($id);
|
$profile = ProfileService::get($id);
|
||||||
|
|
||||||
if(!$profile) {
|
if(!$profile) {
|
||||||
return 'unavailable';
|
return 'unavailable';
|
||||||
|
@ -65,8 +65,8 @@ class MediaTagService
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => (string) $id,
|
'id' => (string) $id,
|
||||||
'username' => $profile->username,
|
'username' => $profile['username'],
|
||||||
'avatar' => $profile->avatarUrl()
|
'avatar' => $profile['avatar']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,41 +4,29 @@ namespace App\Services;
|
||||||
|
|
||||||
use Cache;
|
use Cache;
|
||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Support\Facades\Redis;
|
||||||
|
use App\Transformer\Api\AccountTransformer;
|
||||||
use App\{
|
use League\Fractal;
|
||||||
Follower,
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
Profile
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
};
|
use App\Profile;
|
||||||
|
|
||||||
class ProfileService {
|
class ProfileService {
|
||||||
|
|
||||||
protected $profile;
|
public static function get($id)
|
||||||
protected $profile_prefix;
|
|
||||||
|
|
||||||
public static function build()
|
|
||||||
{
|
{
|
||||||
return new self();
|
$key = 'profile:model:' . $id;
|
||||||
|
$ttl = now()->addHours(4);
|
||||||
|
$res = Cache::remember($key, $ttl, function() use($id) {
|
||||||
|
$profile = Profile::find($id);
|
||||||
|
if(!$profile) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
$fractal = new Fractal\Manager();
|
||||||
public function profile(Profile $profile)
|
$fractal->setSerializer(new ArraySerializer());
|
||||||
{
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||||
$this->profile = $profile;
|
return $fractal->createData($resource)->toArray();
|
||||||
$this->profile_prefix = 'profile:model:'.$profile->id;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function profileId($id)
|
|
||||||
{
|
|
||||||
return Cache::rememberForever('profile:model:'.$id, function() use($id) {
|
|
||||||
return Profile::findOrFail($id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get()
|
|
||||||
{
|
|
||||||
return Cache::rememberForever($this->profile_prefix, function() {
|
|
||||||
return $this->profile;
|
|
||||||
});
|
});
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,10 @@ use App\Status;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use Cache;
|
use Cache;
|
||||||
use App\Services\HashidService;
|
use App\Services\HashidService;
|
||||||
|
use App\Services\LikeService;
|
||||||
use App\Services\MediaTagService;
|
use App\Services\MediaTagService;
|
||||||
|
use App\Services\StatusLabelService;
|
||||||
|
use App\Services\ProfileService;
|
||||||
|
|
||||||
class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
|
@ -32,8 +35,8 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
||||||
'content_text' => $status->caption,
|
'content_text' => $status->caption,
|
||||||
'created_at' => $status->created_at->format('c'),
|
'created_at' => $status->created_at->format('c'),
|
||||||
'emojis' => [],
|
'emojis' => [],
|
||||||
'reblogs_count' => $status->reblogs_count ?? 0,
|
'reblogs_count' => 0,
|
||||||
'favourites_count' => $status->likes_count ?? 0,
|
'favourites_count' => 0,
|
||||||
'reblogged' => null,
|
'reblogged' => null,
|
||||||
'favourited' => null,
|
'favourited' => null,
|
||||||
'muted' => null,
|
'muted' => null,
|
||||||
|
@ -56,7 +59,9 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
|
||||||
'parent' => [],
|
'parent' => [],
|
||||||
'place' => $status->place,
|
'place' => $status->place,
|
||||||
'local' => (bool) $status->local,
|
'local' => (bool) $status->local,
|
||||||
'taggedPeople' => $taggedPeople
|
'taggedPeople' => $taggedPeople,
|
||||||
|
'label' => StatusLabelService::get($status),
|
||||||
|
'liked_by' => LikeService::likedBy($status)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
|
|
||||||
namespace App\Transformer\Api;
|
namespace App\Transformer\Api;
|
||||||
|
|
||||||
|
use App\Like;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use Cache;
|
use Cache;
|
||||||
use App\Services\HashidService;
|
use App\Services\HashidService;
|
||||||
|
use App\Services\LikeService;
|
||||||
use App\Services\MediaTagService;
|
use App\Services\MediaTagService;
|
||||||
use App\Services\StatusLabelService;
|
use App\Services\StatusLabelService;
|
||||||
|
use App\Services\ProfileService;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class StatusTransformer extends Fractal\TransformerAbstract
|
class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
|
@ -34,8 +37,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'content_text' => $status->caption,
|
'content_text' => $status->caption,
|
||||||
'created_at' => $status->created_at->format('c'),
|
'created_at' => $status->created_at->format('c'),
|
||||||
'emojis' => [],
|
'emojis' => [],
|
||||||
'reblogs_count' => $status->reblogs_count ?? 0,
|
'reblogs_count' => 0,
|
||||||
'favourites_count' => $status->likes_count ?? 0,
|
'favourites_count' => 0,
|
||||||
'reblogged' => $status->shared(),
|
'reblogged' => $status->shared(),
|
||||||
'favourited' => $status->liked(),
|
'favourited' => $status->liked(),
|
||||||
'muted' => null,
|
'muted' => null,
|
||||||
|
@ -59,7 +62,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'place' => $status->place,
|
'place' => $status->place,
|
||||||
'local' => (bool) $status->local,
|
'local' => (bool) $status->local,
|
||||||
'taggedPeople' => $taggedPeople,
|
'taggedPeople' => $taggedPeople,
|
||||||
'label' => StatusLabelService::get($status)
|
'label' => StatusLabelService::get($status),
|
||||||
|
'liked_by' => LikeService::likedBy($status)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
public/js/status.js
vendored
BIN
public/js/status.js
vendored
Binary file not shown.
BIN
public/js/timeline.js
vendored
BIN
public/js/timeline.js
vendored
Binary file not shown.
Binary file not shown.
|
@ -220,14 +220,16 @@
|
||||||
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
|
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
|
||||||
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
|
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="reaction-counts font-weight-bold mb-0">
|
<div class="reaction-counts mb-0">
|
||||||
<span style="cursor:pointer;" v-on:click="likesModal">
|
<div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
|
||||||
<span class="like-count">{{status.favourites_count || 0}}</span> likes
|
<span class="like-count">Liked by
|
||||||
|
<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
|
||||||
|
<span v-if="status.liked_by.others == true">
|
||||||
|
and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal">others</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
|
|
||||||
<span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
|
<div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
|
||||||
<a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at">
|
<a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at">
|
||||||
{{timestampFormat()}}
|
{{timestampFormat()}}
|
||||||
|
@ -978,9 +980,6 @@ export default {
|
||||||
window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
|
window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.status.favourites_count == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(this.likes.length) {
|
if(this.likes.length) {
|
||||||
this.$refs.likesModal.show();
|
this.$refs.likesModal.show();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -224,8 +224,13 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="likes font-weight-bold" v-if="expLc(status) == true">
|
<div v-if="status.liked_by.username && status.liked_by.username !== profile.username" class="likes mb-1">
|
||||||
<span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
|
<span class="like-count">Liked by
|
||||||
|
<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
|
||||||
|
<span v-if="status.liked_by.others == true">
|
||||||
|
and <span class="font-weight-bold">others</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="status.pf_type != 'text'" class="caption">
|
<div v-if="status.pf_type != 'text'" class="caption">
|
||||||
<p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;">
|
<p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;">
|
||||||
|
|
|
@ -26,16 +26,9 @@
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}">
|
<li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}">
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a>
|
<a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/reports*')?'active':''}}">
|
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.reports')}}">Reports</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}">
|
<li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}">
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a>
|
<a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a>
|
||||||
</li>
|
</li>
|
||||||
{{-- <li class="nav-item pl-3 {{request()->is('settings/sponsor*')?'active':''}}">
|
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.sponsor')}}">Sponsor</a>
|
|
||||||
</li> --}}
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<hr>
|
<hr>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
@extends('settings.template')
|
|
||||||
|
|
||||||
@section('section')
|
|
||||||
|
|
||||||
<div class="title">
|
|
||||||
<h3 class="font-weight-bold">Reports</h3>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<p class="lead">A list of reports you have made. </p>
|
|
||||||
<table class="table table-responsive">
|
|
||||||
<thead class="bg-light">
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Type</th>
|
|
||||||
<th scope="col">Reported</th>
|
|
||||||
<th scope="col">Status</th>
|
|
||||||
<th scope="col">Created</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($reports as $report)
|
|
||||||
<tr>
|
|
||||||
<td class="font-weight-bold">{{$report->id}}</td>
|
|
||||||
<td class="font-weight-bold">{{$report->type}}</td>
|
|
||||||
<td class="font-weight-bold"><a href="{{$report->reported()->url()}}">{{str_limit($report->reported()->url(), 30)}}</a></td>
|
|
||||||
@if(!$report->admin_seen)
|
|
||||||
<td><span class="text-danger font-weight-bold">Unresolved</span></td>
|
|
||||||
@else
|
|
||||||
<td><span class="text-success font-weight-bold">Resolved</span></td>
|
|
||||||
@endif
|
|
||||||
<td class="font-weight-bold">{{$report->created_at->diffForHumans(null, true, true)}}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="d-flex justify-content-center mt-5 small">
|
|
||||||
{{$reports->links()}}
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
|
@ -351,7 +351,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
|
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
|
||||||
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
|
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
|
||||||
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
|
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
|
||||||
Route::get('reports', 'SettingsController@reportsHome')->name('settings.reports');
|
|
||||||
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
|
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
|
||||||
Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary');
|
Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary');
|
||||||
Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit');
|
Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit');
|
||||||
|
|
Loading…
Reference in a new issue