Add custom content warnings for remote posts

This commit is contained in:
Daniel Supernault 2020-04-20 22:24:27 -06:00
parent 85b537346a
commit 6afc61a409
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 12 additions and 5 deletions

View file

@ -552,6 +552,7 @@ class PublicApiController extends Controller
'reblogs_count',
'scope',
'local',
'cw_summary',
'created_at',
'updated_at'
)->whereProfileId($profile->id)

View file

@ -327,6 +327,8 @@ class Helpers {
$status->is_nsfw = $cw;
$status->scope = $scope;
$status->visibility = $scope;
$status->cw_summary = $cw == true && isset($res['summary']) ?
Purify::clean(strip_tags($res['summary'])) : null;
$status->save();
if($reply_to == null) {
self::importNoteAttachment($res, $status);
@ -404,7 +406,8 @@ class Helpers {
if(empty($username)) {
return;
}
$remoteUsername = "@{$username}@{$domain}";
$remoteUsername = $username;
$webfinger = "@{$username}@{$domain}";
abort_if(!self::validateUrl($res['inbox']), 400);
abort_if(!self::validateUrl($res['id']), 400);
@ -422,6 +425,8 @@ class Helpers {
$profile->remote_url = strtolower($res['id']);
$profile->public_key = $res['publicKey']['publicKeyPem'];
$profile->key_id = $res['publicKey']['id'];
$profile->webfinger = strtolower(Purify::clean($webfinger));
$profile->last_fetched_at = now();
$profile->save();
if($runJobs == true) {
// RemoteFollowImportRecent::dispatch($res, $profile);

View file

@ -73,16 +73,16 @@
<div v-if="status.sensitive == true">
<details class="details-animated" @click="status.sensitive = false;">
<summary>
<p class="mb-0 lead font-weight-bold">CW / NSFW / Hidden Media</p>
<p class="mb-0 lead font-weight-bold">{{status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<a :href="status.url">
<a :href="remotePostUrl(status)">
<img v-once :src="status.thumb" class="w-100 h-100">
</a>
</details>
</div>
<div v-else>
<a :href="status.url">
<a :href="remotePostUrl(status)">
<img v-once :src="status.thumb" class="w-100 h-100">
</a>
<button v-if="status.cw == true && status.sensitive == false" class="btn btn-block btn-primary font-weight-bold rounded-0" @click="status.sensitive = true;">Hide Media</button>
@ -241,7 +241,8 @@
type: status.pf_type,
url: status.url,
sensitive: status.sensitive,
cw: status.sensitive
cw: status.sensitive,
spoiler_text: status.spoiler_text
}
});
let ids = data.map(status => status.id);