Merge pull request #2133 from pixelfed/staging

Add custom content warnings for remote posts
This commit is contained in:
daniel 2020-04-20 22:28:14 -06:00 committed by GitHub
commit bc12ebd0a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 5 deletions

View file

@ -2,6 +2,7 @@
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.10.9...dev) ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.10.9...dev)
### Added ### Added
- Custom content warnings for remote posts ([6afc61a4](https://github.com/pixelfed/pixelfed/commit/6afc61a4))
### Updated ### Updated
- Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc)) - Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc))

View file

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

View file

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

BIN
public/js/rempro.js vendored

Binary file not shown.

Binary file not shown.

View file

@ -73,16 +73,16 @@
<div v-if="status.sensitive == true"> <div v-if="status.sensitive == true">
<details class="details-animated" @click="status.sensitive = false;"> <details class="details-animated" @click="status.sensitive = false;">
<summary> <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> <p class="font-weight-light">(click to show)</p>
</summary> </summary>
<a :href="status.url"> <a :href="remotePostUrl(status)">
<img v-once :src="status.thumb" class="w-100 h-100"> <img v-once :src="status.thumb" class="w-100 h-100">
</a> </a>
</details> </details>
</div> </div>
<div v-else> <div v-else>
<a :href="status.url"> <a :href="remotePostUrl(status)">
<img v-once :src="status.thumb" class="w-100 h-100"> <img v-once :src="status.thumb" class="w-100 h-100">
</a> </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> <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, type: status.pf_type,
url: status.url, url: status.url,
sensitive: status.sensitive, sensitive: status.sensitive,
cw: status.sensitive cw: status.sensitive,
spoiler_text: status.spoiler_text
} }
}); });
let ids = data.map(status => status.id); let ids = data.map(status => status.id);