Merge pull request #2346 from pixelfed/staging
Update Tag People, allow untagging yourself
This commit is contained in:
commit
f2e4522c10
|
@ -71,6 +71,7 @@
|
||||||
- Updated NotificationTransformer, add modlog and tagged types. ([49dab6fb](https://github.com/pixelfed/pixelfed/commit/49dab6fb))
|
- Updated NotificationTransformer, add modlog and tagged types. ([49dab6fb](https://github.com/pixelfed/pixelfed/commit/49dab6fb))
|
||||||
- Updated comments, fix remote reply bug. ([f330616](https://github.com/pixelfed/pixelfed/commit/f330616))
|
- Updated comments, fix remote reply bug. ([f330616](https://github.com/pixelfed/pixelfed/commit/f330616))
|
||||||
- Updated PostComponent, add tagged people to mobile layout. ([7a2c2e78](https://github.com/pixelfed/pixelfed/commit/7a2c2e78))
|
- Updated PostComponent, add tagged people to mobile layout. ([7a2c2e78](https://github.com/pixelfed/pixelfed/commit/7a2c2e78))
|
||||||
|
- Updated Tag People, allow untagging yourself. ([c9452639](https://github.com/pixelfed/pixelfed/commit/c9452639))
|
||||||
|
|
||||||
## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
|
## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -332,6 +332,14 @@ class InternalApiController extends Controller
|
||||||
$media->save();
|
$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) {
|
foreach($tagged as $tg) {
|
||||||
$mt = new MediaTag;
|
$mt = new MediaTag;
|
||||||
$mt->status_id = $status->id;
|
$mt->status_id = $status->id;
|
||||||
|
@ -347,14 +355,6 @@ class InternalApiController extends Controller
|
||||||
MediaTagService::sendNotification($mt);
|
MediaTagService::sendNotification($mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
$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();
|
|
||||||
|
|
||||||
NewStatusPipeline::dispatch($status);
|
NewStatusPipeline::dispatch($status);
|
||||||
Cache::forget('user:account:id:'.$profile->user_id);
|
Cache::forget('user:account:id:'.$profile->user_id);
|
||||||
Cache::forget('profile:status_count:'.$profile->id);
|
Cache::forget('profile:status_count:'.$profile->id);
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\MediaTagService;
|
||||||
use App\MediaTag;
|
use App\MediaTag;
|
||||||
|
use App\Notification;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
@ -11,6 +13,11 @@ use Illuminate\Support\Str;
|
||||||
|
|
||||||
class MediaTagController extends Controller
|
class MediaTagController extends Controller
|
||||||
{
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
public function usernameLookup(Request $request)
|
public function usernameLookup(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
|
@ -52,4 +59,38 @@ class MediaTagController extends Controller
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function untagProfile(Request $request)
|
||||||
|
{
|
||||||
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$this->validate($request, [
|
||||||
|
'status_id' => 'required',
|
||||||
|
'profile_id' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
|
$status_id = $request->input('status_id');
|
||||||
|
$profile_id = (int) $request->input('profile_id');
|
||||||
|
|
||||||
|
abort_if((int) $user->profile_id !== $profile_id, 400);
|
||||||
|
|
||||||
|
$tag = MediaTag::whereStatusId($status_id)
|
||||||
|
->whereProfileId($profile_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if(!$tag) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
Notification::whereItemType('App\MediaTag')
|
||||||
|
->whereItemId($tag->id)
|
||||||
|
->whereProfileId($profile_id)
|
||||||
|
->whereAction('tagged')
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
MediaTagService::untag($status_id, $profile_id);
|
||||||
|
|
||||||
|
return [200];
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,24 @@ class MediaTagService
|
||||||
const CACHE_KEY = 'pf:services:media_tags:id:';
|
const CACHE_KEY = 'pf:services:media_tags:id:';
|
||||||
|
|
||||||
public static function get($mediaId, $usernames = true)
|
public static function get($mediaId, $usernames = true)
|
||||||
|
{
|
||||||
|
return self::coldGet($mediaId, $usernames);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function coldGet($mediaId, $usernames = true)
|
||||||
{
|
{
|
||||||
$k = 'pf:services:media_tags:get:sid:' . $mediaId;
|
$k = 'pf:services:media_tags:get:sid:' . $mediaId;
|
||||||
return Cache::remember($k, now()->addMinutes(60), function() use($mediaId, $usernames) {
|
return Cache::remember($k, now()->addMinutes(60), function() use($mediaId, $usernames) {
|
||||||
$key = self::CACHE_KEY . $mediaId;
|
$key = self::CACHE_KEY . $mediaId;
|
||||||
if(Redis::zCount($key, '-inf', '+inf') == 0) {
|
if(Redis::zCount($key, '-inf', '+inf') == 0) {
|
||||||
return [];
|
$tags = MediaTag::whereStatusId($mediaId)->get();
|
||||||
|
if($tags->count() == 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags as $t) {
|
||||||
|
self::set($mediaId, $t->profile_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$res = Redis::zRange($key, 0, -1);
|
$res = Redis::zRange($key, 0, -1);
|
||||||
if(!$usernames) {
|
if(!$usernames) {
|
||||||
|
@ -52,6 +64,7 @@ class MediaTagService
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'id' => (string) $id,
|
||||||
'username' => $profile->username,
|
'username' => $profile->username,
|
||||||
'avatar' => $profile->avatarUrl()
|
'avatar' => $profile->avatarUrl()
|
||||||
];
|
];
|
||||||
|
@ -75,4 +88,14 @@ class MediaTagService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function untag($statusId, $profileId)
|
||||||
|
{
|
||||||
|
MediaTag::whereStatusId($statusId)
|
||||||
|
->whereProfileId($profileId)
|
||||||
|
->delete();
|
||||||
|
$key = 'pf:services:media_tags:get:sid:' . $statusId;
|
||||||
|
Redis::zRem(self::CACHE_KEY.$statusId, $profileId);
|
||||||
|
Cache::forget($key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
2
public/js/status.js
vendored
2
public/js/status.js
vendored
File diff suppressed because one or more lines are too long
|
@ -24,7 +24,7 @@
|
||||||
"/js/rempos.js": "/js/rempos.js?id=b0e81561d85612cf9aab",
|
"/js/rempos.js": "/js/rempos.js?id=b0e81561d85612cf9aab",
|
||||||
"/js/rempro.js": "/js/rempro.js?id=bfe52f1149330c486da7",
|
"/js/rempro.js": "/js/rempro.js?id=bfe52f1149330c486da7",
|
||||||
"/js/search.js": "/js/search.js?id=2d76d7d28de3b4691bc7",
|
"/js/search.js": "/js/search.js?id=2d76d7d28de3b4691bc7",
|
||||||
"/js/status.js": "/js/status.js?id=8c49c50631efb547da60",
|
"/js/status.js": "/js/status.js?id=14b78a875aac8600d20a",
|
||||||
"/js/story-compose.js": "/js/story-compose.js?id=8768fd0f62554e98ef10",
|
"/js/story-compose.js": "/js/story-compose.js?id=8768fd0f62554e98ef10",
|
||||||
"/js/theme-monokai.js": "/js/theme-monokai.js?id=3b6e62701f12b717cc5c",
|
"/js/theme-monokai.js": "/js/theme-monokai.js?id=3b6e62701f12b717cc5c",
|
||||||
"/js/timeline.js": "/js/timeline.js?id=259969ea820ad53ac48a"
|
"/js/timeline.js": "/js/timeline.js?id=259969ea820ad53ac48a"
|
||||||
|
|
|
@ -595,16 +595,17 @@
|
||||||
title="Tagged People"
|
title="Tagged People"
|
||||||
body-class="list-group-flush py-3 px-0">
|
body-class="list-group-flush py-3 px-0">
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item border-0 py-1" v-for="(user, index) in status.taggedPeople" :key="'modal_taggedpeople_'+index">
|
<div class="list-group-item border-0 py-1" v-for="(taguser, index) in status.taggedPeople" :key="'modal_taggedpeople_'+index">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<a :href="'/'+user.username">
|
<a :href="'/'+taguser.username">
|
||||||
<img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
|
<img class="mr-3 rounded-circle box-shadow" :src="taguser.avatar" :alt="taguser.username + '’s avatar'" width="30px">
|
||||||
</a>
|
</a>
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<p class="pt-1" style="font-size: 14px">
|
<p class="pt-1 d-flex justify-content-between" style="font-size: 14px">
|
||||||
<a :href="'/'+user.username" class="font-weight-bold text-dark">
|
<a :href="'/'+taguser.username" class="font-weight-bold text-dark">
|
||||||
{{user.username}}
|
{{taguser.username}}
|
||||||
</a>
|
</a>
|
||||||
|
<button v-if="taguser.id == user.id" class="btn btn-outline-primary btn-sm py-1 px-3" @click="untagMe()">Untag Me</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1392,6 +1393,22 @@ export default {
|
||||||
|
|
||||||
showTaggedPeopleModal() {
|
showTaggedPeopleModal() {
|
||||||
this.$refs.taggedModal.show();
|
this.$refs.taggedModal.show();
|
||||||
|
},
|
||||||
|
|
||||||
|
untagMe() {
|
||||||
|
this.$refs.taggedModal.hide();
|
||||||
|
let id = this.user.id;
|
||||||
|
axios.post('/api/local/compose/tag/untagme', {
|
||||||
|
status_id: this.statusId,
|
||||||
|
profile_id: id
|
||||||
|
}).then(res => {
|
||||||
|
this.status.taggedPeople = this.status.taggedPeople.filter(t => {
|
||||||
|
return t.id != id;
|
||||||
|
});
|
||||||
|
swal('Untagged', 'You have been untagged from this post.', 'success');
|
||||||
|
}).catch(err => {
|
||||||
|
swal('An Error Occurred', 'Please try again later.', 'error');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,8 @@ return [
|
||||||
'blockingAccounts' => 'Blokowanie kont',
|
'blockingAccounts' => 'Blokowanie kont',
|
||||||
'safetyTips' => 'Wskazówki dot. bezpieczeństwa',
|
'safetyTips' => 'Wskazówki dot. bezpieczeństwa',
|
||||||
'reportSomething' => 'Zgłaszanie treści',
|
'reportSomething' => 'Zgłaszanie treści',
|
||||||
'dataPolicy' => 'Polityka przechowywania danych'
|
'dataPolicy' => 'Polityka przechowywania danych',
|
||||||
|
|
||||||
|
'taggingPeople' => 'Tagowanie ludzi'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -187,7 +187,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::post('compose/media/update/{id}', 'MediaController@composeUpdate')->middleware('throttle:maxComposeMediaUpdatesPerHour,60')->middleware('throttle:maxComposeMediaUpdatesPerDay,1440')->middleware('throttle:maxComposeMediaUpdatesPerMonth,43800');
|
Route::post('compose/media/update/{id}', 'MediaController@composeUpdate')->middleware('throttle:maxComposeMediaUpdatesPerHour,60')->middleware('throttle:maxComposeMediaUpdatesPerDay,1440')->middleware('throttle:maxComposeMediaUpdatesPerMonth,43800');
|
||||||
Route::get('compose/location/search', 'ApiController@composeLocationSearch');
|
Route::get('compose/location/search', 'ApiController@composeLocationSearch');
|
||||||
Route::get('compose/tag/search', 'MediaTagController@usernameLookup');
|
Route::get('compose/tag/search', 'MediaTagController@usernameLookup');
|
||||||
|
Route::post('compose/tag/untagme', 'MediaTagController@untagProfile');
|
||||||
});
|
});
|
||||||
Route::group(['prefix' => 'admin'], function () {
|
Route::group(['prefix' => 'admin'], function () {
|
||||||
Route::post('moderate', 'Api\AdminApiController@moderate');
|
Route::post('moderate', 'Api\AdminApiController@moderate');
|
||||||
|
|
Loading…
Reference in a new issue