mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 15:03:17 +00:00
commit
4c2661b8dd
9 changed files with 128 additions and 167 deletions
|
@ -21,6 +21,9 @@
|
|||
- Updated MediaTransformers, add default blurhash attribute. ([3f14a4c4](https://github.com/pixelfed/pixelfed/commit/3f14a4c4))
|
||||
- Updated Timeline.vue, fix hashtag status previews. ([7768e844](https://github.com/pixelfed/pixelfed/commit/7768e844))
|
||||
- Updated AP helpers, fix statusFetch 404s. ([3419379a](https://github.com/pixelfed/pixelfed/commit/3419379a))
|
||||
- Updated InternalApiController, update discoverPosts method to improve performance. ([9862a855](https://github.com/pixelfed/pixelfed/commit/9862a855))
|
||||
- Updated DiscoverComponent, add blurhash and like/comment counts. ([a8ebdd2e](https://github.com/pixelfed/pixelfed/commit/a8ebdd2e))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)
|
||||
### Added
|
||||
|
|
|
@ -6,6 +6,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class AccountLog extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['*'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
|
|
@ -35,6 +35,8 @@ use Illuminate\Support\Str;
|
|||
use App\Services\MediaTagService;
|
||||
use App\Services\ModLogService;
|
||||
use App\Services\PublicTimelineService;
|
||||
use App\Services\SnowflakeService;
|
||||
use App\Services\StatusService;
|
||||
|
||||
class InternalApiController extends Controller
|
||||
{
|
||||
|
@ -82,37 +84,27 @@ class InternalApiController extends Controller
|
|||
$following = array_merge($following, $filters);
|
||||
|
||||
$sql = config('database.default') !== 'pgsql';
|
||||
|
||||
$min_id = SnowflakeService::byDate(now()->subMonths(3));
|
||||
$posts = Status::select(
|
||||
'id',
|
||||
'caption',
|
||||
'is_nsfw',
|
||||
'profile_id',
|
||||
'type',
|
||||
'uri',
|
||||
'created_at'
|
||||
)
|
||||
->whereNull('uri')
|
||||
->whereIn('type', ['photo','photo:album', 'video'])
|
||||
->whereIsNsfw(false)
|
||||
->whereVisibility('public')
|
||||
->whereNotIn('profile_id', $following)
|
||||
->when($sql, function($q, $s) {
|
||||
return $q->where('created_at', '>', now()->subMonths(3));
|
||||
})
|
||||
->with('media')
|
||||
->where('id', '>', $min_id)
|
||||
->inRandomOrder()
|
||||
->latest()
|
||||
->take(39)
|
||||
->get();
|
||||
->pluck('id');
|
||||
|
||||
$res = [
|
||||
'posts' => $posts->map(function($post) {
|
||||
return [
|
||||
'type' => $post->type,
|
||||
'url' => $post->url(),
|
||||
'thumb' => $post->thumb(),
|
||||
];
|
||||
return StatusService::get($post);
|
||||
})
|
||||
];
|
||||
return response()->json($res);
|
||||
|
@ -323,117 +315,7 @@ class InternalApiController extends Controller
|
|||
|
||||
public function composePost(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'caption' => 'nullable|string|max:'.config('pixelfed.max_caption_length', 500),
|
||||
'media.*' => 'required',
|
||||
'media.*.id' => 'required|integer|min:1',
|
||||
'media.*.filter_class' => 'nullable|alpha_dash|max:30',
|
||||
'media.*.license' => 'nullable|string|max:140',
|
||||
'media.*.alt' => 'nullable|string|max:140',
|
||||
'cw' => 'nullable|boolean',
|
||||
'visibility' => 'required|string|in:public,private,unlisted|min:2|max:10',
|
||||
'place' => 'nullable',
|
||||
'comments_disabled' => 'nullable',
|
||||
'tagged' => 'nullable'
|
||||
]);
|
||||
|
||||
if(config('costar.enabled') == true) {
|
||||
$blockedKeywords = config('costar.keyword.block');
|
||||
if($blockedKeywords !== null && $request->caption) {
|
||||
$keywords = config('costar.keyword.block');
|
||||
foreach($keywords as $kw) {
|
||||
if(Str::contains($request->caption, $kw) == true) {
|
||||
abort(400, 'Invalid object');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
$visibility = $request->input('visibility');
|
||||
$medias = $request->input('media');
|
||||
$attachments = [];
|
||||
$status = new Status;
|
||||
$mimes = [];
|
||||
$place = $request->input('place');
|
||||
$cw = $request->input('cw');
|
||||
$tagged = $request->input('tagged');
|
||||
|
||||
foreach($medias as $k => $media) {
|
||||
if($k + 1 > config('pixelfed.max_album_length')) {
|
||||
continue;
|
||||
}
|
||||
$m = Media::findOrFail($media['id']);
|
||||
if($m->profile_id !== $profile->id || $m->status_id) {
|
||||
abort(403, 'Invalid media id');
|
||||
}
|
||||
$m->filter_class = in_array($media['filter_class'], Filter::classes()) ? $media['filter_class'] : null;
|
||||
$m->license = $media['license'];
|
||||
$m->caption = isset($media['alt']) ? strip_tags($media['alt']) : null;
|
||||
$m->order = isset($media['cursor']) && is_int($media['cursor']) ? (int) $media['cursor'] : $k;
|
||||
if($cw == true || $profile->cw == true) {
|
||||
$m->is_nsfw = $cw;
|
||||
$status->is_nsfw = $cw;
|
||||
}
|
||||
$m->save();
|
||||
$attachments[] = $m;
|
||||
array_push($mimes, $m->mime);
|
||||
}
|
||||
|
||||
$mediaType = StatusController::mimeTypeCheck($mimes);
|
||||
|
||||
if(in_array($mediaType, ['photo', 'video', 'photo:album']) == false) {
|
||||
abort(400, __('exception.compose.invalid.album'));
|
||||
}
|
||||
|
||||
if($place && is_array($place)) {
|
||||
$status->place_id = $place['id'];
|
||||
}
|
||||
|
||||
if($request->filled('comments_disabled')) {
|
||||
$status->comments_disabled = (bool) $request->input('comments_disabled');
|
||||
}
|
||||
|
||||
$status->caption = strip_tags($request->caption);
|
||||
$status->scope = 'draft';
|
||||
$status->profile_id = $profile->id;
|
||||
$status->save();
|
||||
|
||||
foreach($attachments as $media) {
|
||||
$media->status_id = $status->id;
|
||||
$media->save();
|
||||
}
|
||||
|
||||
$visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility;
|
||||
$cw = $profile->cw == true ? true : $cw;
|
||||
$status->is_nsfw = $cw;
|
||||
$status->visibility = $visibility;
|
||||
$status->scope = $visibility;
|
||||
$status->type = $mediaType;
|
||||
$status->save();
|
||||
|
||||
foreach($tagged as $tg) {
|
||||
$mt = new MediaTag;
|
||||
$mt->status_id = $status->id;
|
||||
$mt->media_id = $status->media->first()->id;
|
||||
$mt->profile_id = $tg['id'];
|
||||
$mt->tagged_username = $tg['name'];
|
||||
$mt->is_public = true; // (bool) $tg['privacy'] ?? 1;
|
||||
$mt->metadata = json_encode([
|
||||
'_v' => 1,
|
||||
]);
|
||||
$mt->save();
|
||||
MediaTagService::set($mt->status_id, $mt->profile_id);
|
||||
MediaTagService::sendNotification($mt);
|
||||
}
|
||||
|
||||
NewStatusPipeline::dispatch($status);
|
||||
Cache::forget('user:account:id:'.$profile->user_id);
|
||||
Cache::forget('_api:statuses:recent_9:'.$profile->id);
|
||||
Cache::forget('profile:status_count:'.$profile->id);
|
||||
Cache::forget($user->storageUsedKey());
|
||||
return $status->url();
|
||||
abort(400, 'Endpoint deprecated');
|
||||
}
|
||||
|
||||
public function bookmarks(Request $request)
|
||||
|
|
|
@ -219,20 +219,21 @@ class SeasonalController extends Controller
|
|||
{
|
||||
abort_if(now()->gt('2021-03-01 00:00:00'), 404);
|
||||
abort_if(config('database.default') != 'mysql', 404);
|
||||
$this->validate($request, [
|
||||
'profile_id' => 'required',
|
||||
'type' => 'required|string|in:view,hide'
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$log = new AccountLog();
|
||||
$log->user_id = $user->id;
|
||||
$log->item_type = 'App\User';
|
||||
$log->item_id = $user->id;
|
||||
$log->action = $request->input('type') == 'view' ? 'seasonal.my2020.view' : 'seasonal.my2020.hide';
|
||||
$log->ip_address = $request->ip();
|
||||
$log->user_agent = $request->user_agent();
|
||||
$log->save();
|
||||
$log = AccountLog::firstOrCreate([
|
||||
[
|
||||
'item_type' => 'App\User',
|
||||
'item_id' => $user->id,
|
||||
'user_id' => $user->id,
|
||||
'action' => 'seasonal.my2020.view'
|
||||
],
|
||||
[
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => $request->userAgent()
|
||||
]
|
||||
]);
|
||||
return response()->json(200);
|
||||
}
|
||||
}
|
||||
|
|
BIN
public/js/discover.js
vendored
BIN
public/js/discover.js
vendored
Binary file not shown.
Binary file not shown.
|
@ -39,13 +39,46 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row p-0" style="display: flex;">
|
||||
<div v-for="(post, index) in trending.slice(0, 12)" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
||||
<a class="card info-overlay card-md-border-0" :href="post.url">
|
||||
<div v-for="(s, index) in trending.slice(0, 12)" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
||||
<a class="card info-overlay card-md-border-0" :href="s.url">
|
||||
<div class="square">
|
||||
<span v-if="post.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
||||
<span v-if="post.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
||||
<span v-if="post.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
||||
<div class="square-content" v-bind:style="{ 'background-image': 'url(' + post.media_attachments[0].preview_url + ')' }">
|
||||
<div v-if="s.sensitive" class="square-content">
|
||||
<div class="info-overlay-text-label">
|
||||
<h5 class="text-white m-auto font-weight-bold">
|
||||
<span>
|
||||
<span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
<blur-hash-canvas
|
||||
width="32"
|
||||
height="32"
|
||||
:hash="s.media_attachments[0].blurhash"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="square-content">
|
||||
|
||||
<blur-hash-image
|
||||
width="32"
|
||||
height="32"
|
||||
:hash="s.media_attachments[0].blurhash"
|
||||
:src="s.media_attachments[0].preview_url"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
||||
<span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
||||
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
||||
<div class="info-overlay-text">
|
||||
<h5 class="text-white m-auto font-weight-bold">
|
||||
<span>
|
||||
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
|
||||
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
|
||||
</span>
|
||||
<span>
|
||||
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
|
||||
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -126,13 +159,46 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row p-0" style="display: flex;">
|
||||
<div v-for="(post, index) in posts" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
||||
<a class="card info-overlay card-md-border-0" :href="post.url">
|
||||
<div v-for="(s, index) in posts" class="col-4 p-1 p-sm-2 p-md-3 pt-0">
|
||||
<a class="card info-overlay card-md-border-0" :href="s.url">
|
||||
<div class="square">
|
||||
<span v-if="post.type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
||||
<span v-if="post.type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
||||
<span v-if="post.type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
||||
<div class="square-content" v-bind:style="{ 'background-image': 'url(' + post.thumb + ')' }">
|
||||
<div v-if="s.sensitive" class="square-content">
|
||||
<div class="info-overlay-text-label">
|
||||
<h5 class="text-white m-auto font-weight-bold">
|
||||
<span>
|
||||
<span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
<blur-hash-canvas
|
||||
width="32"
|
||||
height="32"
|
||||
:hash="s.media_attachments[0].blurhash"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="square-content">
|
||||
|
||||
<blur-hash-image
|
||||
width="32"
|
||||
height="32"
|
||||
:hash="s.media_attachments[0].blurhash"
|
||||
:src="s.media_attachments[0].preview_url"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
|
||||
<span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
|
||||
<span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
|
||||
<div class="info-overlay-text">
|
||||
<h5 class="text-white m-auto font-weight-bold">
|
||||
<span>
|
||||
<span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
|
||||
<span class="d-flex-inline">{{formatCount(s.favourites_count)}}</span>
|
||||
</span>
|
||||
<span>
|
||||
<span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
|
||||
<span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -314,6 +380,10 @@
|
|||
.then(res => {
|
||||
this.places = res.data;
|
||||
});
|
||||
},
|
||||
|
||||
formatCount(s) {
|
||||
return App.util.format.count(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
@if(config('instance.restricted.enabled') == false)
|
||||
<footer>
|
||||
<div class="container py-5">
|
||||
<p class="d-flex flex-wrap justify-content-center mb-0 text-uppercase font-weight-bold small text-justify">
|
||||
<a href="{{route('site.about')}}" class="text-primary p-2">{{__('site.about')}}</a>
|
||||
@if(config('instance.contact.enabled') || config('instance.email'))
|
||||
<a href="{{route('site.contact')}}" class="text-primary p-2">{{__('site.contact-us')}}</a>
|
||||
@endif
|
||||
<a href="{{route('site.help')}}" class="text-primary p-2">{{__('site.help')}}</a>
|
||||
<a href="{{route('site.terms')}}" class="text-primary p-2">{{__('site.terms')}}</a>
|
||||
<a href="{{route('site.privacy')}}" class="text-primary p-2">{{__('site.privacy')}}</a>
|
||||
<a href="{{route('discover.places')}}" class="text-primary p-2">{{__('site.places')}}</a>
|
||||
<a href="{{route('site.language')}}" class="text-primary p-2">{{__('site.language')}}</a>
|
||||
<a href="https://pixelfed.org" class="text-muted p-2 ml-md-auto" rel="noopener" title="version {{config('pixelfed.version')}}" data-toggle="tooltip">Powered by Pixelfed</a>
|
||||
<p class="text-center text-uppercase font-weight-bold small text-justify">
|
||||
<a href="{{route('site.about')}}" class="text-dark p-2">{{__('site.about')}}</a>
|
||||
<a href="{{route('site.help')}}" class="text-dark p-2">{{__('site.help')}}</a>
|
||||
<a href="{{route('site.terms')}}" class="text-dark p-2">{{__('site.terms')}}</a>
|
||||
<a href="{{route('site.privacy')}}" class="text-dark p-2">{{__('site.privacy')}}</a>
|
||||
<a href="{{route('site.language')}}" class="text-dark p-2">{{__('site.language')}}</a>
|
||||
</p>
|
||||
<p class="text-center text-muted small mb-0">
|
||||
<span class="text-muted">© {{date('Y')}} {{config('pixelfed.domain.app')}}</span>
|
||||
<span class="mx-2">·</span>
|
||||
<a href="https://pixelfed.org" class="text-muted font-weight-bold" rel="noopener">Powered by Pixelfed</a>
|
||||
<span class="mx-2">·</span>
|
||||
<span class="text-muted">v{{config('pixelfed.version')}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li>
|
||||
<a class="nav-link font-weight-bold text-primary" href="{{ route('login') }}" title="Login">
|
||||
<a class="nav-link font-weight-bold text-dark" href="{{ route('login') }}" title="Login">
|
||||
{{ __('Login') }}
|
||||
</a>
|
||||
</li>
|
||||
@if(config('pixelfed.open_registration') && config('instance.restricted.enabled') == false)
|
||||
<li>
|
||||
<a class="nav-link font-weight-bold" href="{{ route('register') }}" title="Register">
|
||||
{{ __('Register') }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ml-3 nav-link font-weight-bold text-dark" href="{{ route('register') }}" title="Register">
|
||||
{{ __('Register') }}
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
@else
|
||||
<div class="ml-auto">
|
||||
|
@ -52,7 +52,7 @@
|
|||
</li>
|
||||
<li class="nav-item px-md-2 d-none d-md-block">
|
||||
<a class="nav-link font-weight-bold text-dark" href="/account/activity" title="Notifications" data-toggle="tooltip" data-placement="bottom">
|
||||
<i class="far fa-bell fa-lg" style="vertical-align: middle;"></i>
|
||||
<i class="far fa-bell fa-lg"></i>
|
||||
<span class="sr-only">Notifications</span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue