Update Status caption logic, stop storing duplicate html caption in db and defer to cached StatusService rendering

This commit is contained in:
Daniel Supernault 2024-11-19 03:45:52 -07:00
parent 27960c3a0a
commit 9eeb7b6741
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
18 changed files with 776 additions and 805 deletions

View file

@ -2,17 +2,16 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\ImportPost;
use App\Services\ImportService;
use App\Media;
use App\Models\ImportPost;
use App\Profile;
use App\Status;
use Storage;
use App\Services\AccountService;
use App\Services\ImportService;
use App\Services\MediaPathService;
use App\Status;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use App\Util\Lexer\Autolink;
use Storage;
class TransformImports extends Command
{
@ -52,6 +51,7 @@ class TransformImports extends Command
if (! $profile) {
$ip->skip_missing_media = true;
$ip->save();
continue;
}
@ -66,6 +66,7 @@ class TransformImports extends Command
if ($exists == true) {
$ip->skip_missing_media = true;
$ip->save();
continue;
}
@ -73,6 +74,7 @@ class TransformImports extends Command
if (! $idk) {
$ip->skip_missing_media = true;
$ip->save();
continue;
}
@ -81,6 +83,7 @@ class TransformImports extends Command
ImportService::getPostCount($profile->id, true);
$ip->skip_missing_media = true;
$ip->save();
continue;
}
@ -96,6 +99,7 @@ class TransformImports extends Command
if ($missingMedia === true) {
$ip->skip_missing_media = true;
$ip->save();
continue;
}
@ -103,7 +107,6 @@ class TransformImports extends Command
$status = new Status;
$status->profile_id = $pid;
$status->caption = $caption;
$status->rendered = strlen(trim($caption)) ? Autolink::create()->autolink($ip->caption) : null;
$status->type = $ip->post_type;
$status->scope = 'unlisted';
@ -120,6 +123,7 @@ class TransformImports extends Command
if (! Storage::exists($og)) {
$ip->skip_missing_media = true;
$ip->save();
continue;
}
$size = Storage::size($og);

View file

@ -3490,8 +3490,7 @@ class ApiV1Controller extends Controller
return [];
}
$content = strip_tags($request->input('status'));
$rendered = Autolink::create()->autolink($content);
$content = $request->filled('status') ? strip_tags(Purify::clean($request->input('status'))) : null;
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
@ -3505,7 +3504,6 @@ class ApiV1Controller extends Controller
$status = new Status;
$status->caption = $content;
$status->rendered = $rendered;
$status->scope = $visibility;
$status->visibility = $visibility;
$status->profile_id = $user->profile_id;
@ -3530,7 +3528,6 @@ class ApiV1Controller extends Controller
if (! $in_reply_to_id) {
$status = new Status;
$status->caption = $content;
$status->rendered = $rendered;
$status->profile_id = $user->profile_id;
$status->is_nsfw = $cw;
$status->cw_summary = $spoilerText;

View file

@ -37,7 +37,6 @@ use App\Status;
use App\StatusArchived;
use App\User;
use App\UserSetting;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\RestrictedNames;
use Cache;
use DB;
@ -49,6 +48,7 @@ use Jenssegers\Agent\Agent;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use Mail;
use Purify;
class ApiV1Dot1Controller extends Controller
{
@ -1293,14 +1293,12 @@ class ApiV1Dot1Controller extends Controller
return [];
}
$content = strip_tags($request->input('status'));
$rendered = Autolink::create()->autolink($content);
$content = $request->filled('status') ? strip_tags(Purify::clean($request->input('status'))) : null;
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
$status = new Status;
$status->caption = $content;
$status->rendered = $rendered;
$status->profile_id = $user->profile_id;
$status->is_nsfw = $cw;
$status->cw_summary = $spoilerText;

View file

@ -8,12 +8,12 @@ use App\Services\StatusService;
use App\Status;
use App\Transformer\Api\StatusTransformer;
use App\UserFilter;
use App\Util\Lexer\Autolink;
use Auth;
use DB;
use Illuminate\Http\Request;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use Purify;
class CommentController extends Controller
{
@ -56,12 +56,10 @@ class CommentController extends Controller
$reply = DB::transaction(function () use ($comment, $status, $profile, $nsfw) {
$scope = $profile->is_private == true ? 'private' : 'public';
$autolink = Autolink::create()->autolink($comment);
$reply = new Status();
$reply = new Status;
$reply->profile_id = $profile->id;
$reply->is_nsfw = $nsfw;
$reply->caption = e($comment);
$reply->rendered = $autolink;
$reply->caption = Purify::clean($comment);
$reply->in_reply_to_id = $status->id;
$reply->in_reply_to_profile_id = $status->profile_id;
$reply->scope = $scope;
@ -76,9 +74,9 @@ class CommentController extends Controller
CommentPipeline::dispatch($status, $reply);
if ($request->ajax()) {
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$entity = new Fractal\Resource\Item($reply, new StatusTransformer());
$fractal = new Fractal\Manager;
$fractal->setSerializer(new ArraySerializer);
$entity = new Fractal\Resource\Item($reply, new StatusTransformer);
$entity = $fractal->createData($entity)->toArray();
$response = [
'code' => 200,

View file

@ -25,7 +25,6 @@ use App\Services\UserStorageService;
use App\Status;
use App\Transformer\Api\MediaTransformer;
use App\UserFilter;
use App\Util\Lexer\Autolink;
use App\Util\Media\Filter;
use App\Util\Media\License;
use Auth;
@ -43,8 +42,8 @@ class ComposeController extends Controller
public function __construct()
{
$this->middleware('auth');
$this->fractal = new Fractal\Manager();
$this->fractal->setSerializer(new ArraySerializer());
$this->fractal = new Fractal\Manager;
$this->fractal->setSerializer(new ArraySerializer);
}
public function show(Request $request)
@ -112,14 +111,14 @@ class ComposeController extends Controller
abort_if(MediaBlocklistService::exists($hash) == true, 451);
$media = new Media();
$media = new Media;
$media->status_id = null;
$media->profile_id = $profile->id;
$media->user_id = $user->id;
$media->media_path = $path;
$media->original_sha256 = $hash;
$media->size = $photo->getSize();
$media->caption = "";
$media->caption = '';
$media->mime = $mime;
$media->filter_class = $filterClass;
$media->filter_name = $filterName;
@ -151,7 +150,7 @@ class ComposeController extends Controller
$user->save();
Cache::forget($limitKey);
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
$resource = new Fractal\Resource\Item($media, new MediaTransformer);
$res = $this->fractal->createData($resource)->toArray();
$res['preview_url'] = $preview_url;
$res['url'] = $url;
@ -571,7 +570,6 @@ class ComposeController extends Controller
}
$status->caption = strip_tags($request->caption);
$status->rendered = Autolink::create()->autolink($status->caption);
$status->scope = 'draft';
$status->visibility = 'draft';
$status->profile_id = $profile->id;
@ -693,7 +691,6 @@ class ComposeController extends Controller
$status->visibility = $visibility;
$status->scope = $visibility;
$status->type = 'text';
$status->rendered = Autolink::create()->autolink($status->caption);
$status->entities = json_encode(array_merge([
'timg' => [
'version' => 0,
@ -806,7 +803,6 @@ class ComposeController extends Controller
$status = new Status;
$status->profile_id = $request->user()->profile_id;
$status->caption = $request->input('caption');
$status->rendered = Autolink::create()->autolink($status->caption);
$status->visibility = 'draft';
$status->scope = 'draft';
$status->type = 'poll';

View file

@ -22,6 +22,7 @@ use App\Services\WebfingerService;
use App\Status;
use App\UserFilter;
use App\Util\ActivityPub\Helpers;
use App\Util\Lexer\Autolink;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@ -326,7 +327,6 @@ class DirectMessageController extends Controller
$status = new Status;
$status->profile_id = $profile->id;
$status->caption = $msg;
$status->rendered = $msg;
$status->visibility = 'direct';
$status->scope = 'direct';
$status->in_reply_to_profile_id = $recipient->id;
@ -636,7 +636,6 @@ class DirectMessageController extends Controller
$status = new Status;
$status->profile_id = $profile->id;
$status->caption = null;
$status->rendered = null;
$status->visibility = 'direct';
$status->scope = 'direct';
$status->in_reply_to_profile_id = $recipient->id;
@ -830,6 +829,11 @@ class DirectMessageController extends Controller
{
$profile = $dm->author;
$url = $dm->recipient->sharedInbox ?? $dm->recipient->inbox_url;
$status = $dm->status;
if (! $status) {
return;
}
$tags = [
[
@ -839,6 +843,8 @@ class DirectMessageController extends Controller
],
];
$content = $status->caption ? Autolink::create()->autolink($status->caption) : null;
$body = [
'@context' => [
'https://w3id.org/security/v1',
@ -854,7 +860,7 @@ class DirectMessageController extends Controller
'id' => $dm->status->url(),
'type' => 'Note',
'summary' => null,
'content' => $dm->status->rendered ?? $dm->status->caption,
'content' => $content,
'inReplyTo' => null,
'published' => $dm->status->created_at->toAtomString(),
'url' => $dm->status->url(),

View file

@ -2,13 +2,14 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use App\Models\Group;
use App\Models\GroupPost;
use App\Status;
use App\Models\InstanceActor;
use App\Services\MediaService;
use App\Status;
use App\Util\Lexer\Autolink;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class GroupFederationController extends Controller
{
@ -16,6 +17,7 @@ class GroupFederationController extends Controller
{
$group = Group::whereLocal(true)->whereActivitypub(true)->findOrFail($id);
$res = $this->showGroupObject($group);
return response()->json($res, 200, [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
@ -32,7 +34,7 @@ class GroupFederationController extends Controller
'type' => 'Group',
'attributedTo' => [
'type' => 'Person',
'id' => $group->admin->permalink()
'id' => $group->admin->permalink(),
],
// 'endpoints' => [
// 'sharedInbox' => config('app.url') . '/f/inbox'
@ -43,23 +45,24 @@ class GroupFederationController extends Controller
'owner' => $group->permalink(),
'publicKeyPem' => InstanceActor::first()->public_key,
],
'url' => $group->permalink()
'url' => $group->permalink(),
];
if ($group->metadata && isset($group->metadata['avatar'])) {
$res['icon'] = [
'type' => 'Image',
'url' => $group->metadata['avatar']['url']
'url' => $group->metadata['avatar']['url'],
];
}
if ($group->metadata && isset($group->metadata['header'])) {
$res['image'] = [
'type' => 'Image',
'url' => $group->metadata['header']['url']
'url' => $group->metadata['header']['url'],
];
}
ksort($res);
return $res;
});
}
@ -70,7 +73,7 @@ class GroupFederationController extends Controller
$gp = GroupPost::whereGroupId($gid)->findOrFail($sid);
$status = Status::findOrFail($gp->status_id);
// permission check
$content = $status->caption ? Autolink::create()->autolink($status->caption) : null;
$res = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $gp->url(),
@ -78,7 +81,7 @@ class GroupFederationController extends Controller
'type' => 'Note',
'summary' => null,
'content' => $status->rendered ?? $status->caption,
'content' => $content,
'inReplyTo' => null,
'published' => $status->created_at->toAtomString(),
@ -94,9 +97,10 @@ class GroupFederationController extends Controller
'target' => [
'type' => 'Collection',
'id' => $group->permalink('/wall'),
'attributedTo' => $group->permalink()
]
'attributedTo' => $group->permalink(),
],
];
// ksort($res);
return response()->json($res, 200, [], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}

View file

@ -2,48 +2,29 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\{
AccountInterstitial,
Bookmark,
DirectMessage,
DiscoverCategory,
Hashtag,
Follower,
Like,
Media,
MediaTag,
Notification,
Profile,
StatusHashtag,
Status,
User,
UserFilter,
};
use Auth,Cache;
use Illuminate\Support\Facades\Redis;
use Carbon\Carbon;
use League\Fractal;
use App\Transformer\Api\{
AccountTransformer,
StatusTransformer,
// StatusMediaContainerTransformer,
};
use App\Util\Media\Filter;
use App\Jobs\StatusPipeline\NewStatusPipeline;
use App\AccountInterstitial;
use App\Bookmark;
use App\DirectMessage;
use App\DiscoverCategory;
use App\Follower;
use App\Jobs\ModPipeline\HandleSpammerPipeline;
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use Illuminate\Validation\Rule;
use Illuminate\Support\Str;
use App\Services\MediaTagService;
use App\Profile;
use App\Services\BookmarkService;
use App\Services\DiscoverService;
use App\Services\ModLogService;
use App\Services\PublicTimelineService;
use App\Services\SnowflakeService;
use App\Services\StatusService;
use App\Services\UserFilterService;
use App\Services\DiscoverService;
use App\Services\BookmarkService;
use App\Status; // StatusMediaContainerTransformer,
use App\Transformer\Api\StatusTransformer;
use App\User;
use Auth;
use Cache;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Validation\Rule;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
class InternalApiController extends Controller
{
@ -52,8 +33,8 @@ class InternalApiController extends Controller
public function __construct()
{
$this->middleware('auth');
$this->fractal = new Fractal\Manager();
$this->fractal->setSerializer(new ArraySerializer());
$this->fractal = new Fractal\Manager;
$this->fractal->setSerializer(new ArraySerializer);
}
// deprecated v2 compose api
@ -63,10 +44,7 @@ class InternalApiController extends Controller
}
// deprecated
public function discover(Request $request)
{
return;
}
public function discover(Request $request) {}
public function discoverPosts(Request $request)
{
@ -84,6 +62,7 @@ class InternalApiController extends Controller
})
->take(12)
->values();
return response()->json(compact('posts'));
}
@ -110,7 +89,7 @@ class InternalApiController extends Controller
public function statusReplies(Request $request, int $id)
{
$this->validate($request, [
'limit' => 'nullable|int|min:1|max:6'
'limit' => 'nullable|int|min:1|max:6',
]);
$parent = Status::whereScope('public')->findOrFail($id);
$limit = $request->input('limit') ?? 3;
@ -118,16 +97,13 @@ class InternalApiController extends Controller
->orderBy('created_at', 'desc')
->take($limit)
->get();
$resource = new Fractal\Resource\Collection($children, new StatusTransformer());
$resource = new Fractal\Resource\Collection($children, new StatusTransformer);
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
}
public function stories(Request $request)
{
}
public function stories(Request $request) {}
public function discoverCategories(Request $request)
{
@ -136,9 +112,10 @@ class InternalApiController extends Controller
return [
'name' => $item->name,
'url' => $item->url(),
'thumb' => $item->thumb()
'thumb' => $item->thumb(),
];
});
return response()->json($res);
}
@ -153,15 +130,15 @@ class InternalApiController extends Controller
'addcw',
'remcw',
'unlist',
'spammer'
])
'spammer',
]),
],
'item_id' => 'required|integer|min:1',
'item_type' => [
'required',
'string',
Rule::in(['profile', 'status'])
]
Rule::in(['profile', 'status']),
],
]);
$action = $request->input('action');
@ -184,7 +161,7 @@ class InternalApiController extends Controller
->action('admin.status.moderate')
->metadata([
'action' => 'cw',
'message' => 'Success!'
'message' => 'Success!',
])
->accessLevel('admin')
->save();
@ -229,7 +206,7 @@ class InternalApiController extends Controller
->action('admin.status.moderate')
->metadata([
'action' => 'remove_cw',
'message' => 'Success!'
'message' => 'Success!',
])
->accessLevel('admin')
->save();
@ -255,7 +232,7 @@ class InternalApiController extends Controller
->action('admin.status.moderate')
->metadata([
'action' => 'unlist',
'message' => 'Success!'
'message' => 'Success!',
])
->accessLevel('admin')
->save();
@ -299,7 +276,7 @@ class InternalApiController extends Controller
->action('admin.status.moderate')
->metadata([
'action' => 'spammer',
'message' => 'Success!'
'message' => 'Success!',
])
->accessLevel('admin')
->save();
@ -307,6 +284,7 @@ class InternalApiController extends Controller
}
StatusService::del($status->id, true);
return ['msg' => 200];
}
@ -331,6 +309,7 @@ class InternalApiController extends Controller
if ($status) {
BookmarkService::add($pid, $status['id']);
}
return $status;
})
->filter(function ($bookmark) {
@ -350,7 +329,7 @@ class InternalApiController extends Controller
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'since_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
'limit' => 'nullable|integer|min:1|max:24'
'limit' => 'nullable|integer|min:1|max:24',
]);
$profile = Profile::whereNull('status')->findOrFail($id);
@ -369,17 +348,19 @@ class InternalApiController extends Controller
$pid = Auth::user()->profile->id;
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
$following = Follower::whereProfileId($pid)->pluck('following_id');
return $following->push($pid)->toArray();
});
$visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : [];
$visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : [];
} else {
if (Auth::check()) {
$pid = Auth::user()->profile->id;
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
$following = Follower::whereProfileId($pid)->pluck('following_id');
return $following->push($pid)->toArray();
});
$visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
$visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
} else {
$visibility = ['public', 'unlisted'];
}
@ -391,7 +372,6 @@ class InternalApiController extends Controller
'id',
'uri',
'caption',
'rendered',
'profile_id',
'type',
'in_reply_to_id',
@ -411,7 +391,7 @@ class InternalApiController extends Controller
->limit($limit)
->get();
$resource = new Fractal\Resource\Collection($timeline, new StatusTransformer());
$resource = new Fractal\Resource\Collection($timeline, new StatusTransformer);
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
@ -431,6 +411,7 @@ class InternalApiController extends Controller
{
$pid = $request->user()->profile_id;
$exists = Redis::sismember('email:manual', $pid);
return view('account.email.request_verification', compact('exists'));
}
@ -438,6 +419,7 @@ class InternalApiController extends Controller
{
$pid = $request->user()->profile_id;
Redis::sadd('email:manual', $pid);
return redirect('/i/verify-email')->with(['status' => 'Successfully sent manual verification request!']);
}
}

View file

@ -2,12 +2,10 @@
namespace App\Http\Controllers;
use App\Status;
use Auth;
use DB;
use Illuminate\Http\Request;
use App\{
Profile,
Status,
};
use Auth, DB, Purify;
use Illuminate\Validation\Rule;
class MicroController extends Controller
@ -23,7 +21,7 @@ class MicroController extends Controller
'type' => [
'required',
'string',
Rule::in(['text'])
Rule::in(['text']),
],
'title' => 'nullable|string|max:140',
'content' => 'required|string|max:500',
@ -34,9 +32,9 @@ class MicroController extends Controller
'public',
'unlisted',
'private',
'draft'
])
]
'draft',
]),
],
]);
$profile = Auth::user()->profile;
$title = $request->input('title');
@ -48,7 +46,6 @@ class MicroController extends Controller
$status->type = 'text';
$status->profile_id = $profile->id;
$status->caption = strip_tags($content);
$status->rendered = Purify::clean($content);
$status->is_nsfw = false;
// TODO: remove deprecated visibility in favor of scope
@ -56,12 +53,14 @@ class MicroController extends Controller
$status->scope = $visibility;
$status->entities = json_encode(['title' => $title]);
$status->save();
return $status;
});
$fractal = new \League\Fractal\Manager();
$fractal->setSerializer(new \League\Fractal\Serializer\ArraySerializer());
$s = new \League\Fractal\Resource\Item($status, new \App\Transformer\Api\StatusTransformer());
$fractal = new \League\Fractal\Manager;
$fractal->setSerializer(new \League\Fractal\Serializer\ArraySerializer);
$s = new \League\Fractal\Resource\Item($status, new \App\Transformer\Api\StatusTransformer);
return $fractal->createData($s)->toArray();
}
}

View file

@ -8,6 +8,7 @@ use App\Profile;
use App\Services\WebfingerService;
use App\Status;
use App\Util\ActivityPub\Helpers;
use App\Util\Lexer\Autolink;
use Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
@ -320,17 +321,21 @@ class SearchController extends Controller
if (Status::whereUri($tag)->whereLocal(false)->exists()) {
$item = Status::whereUri($tag)->first();
if (! $item) {
return;
}
$media = $item->firstMedia();
$url = null;
if ($media) {
$url = $media->remote_url;
}
$content = $item->caption ? Autolink::create()->autolink($item->caption) : null;
$this->tokens['posts'] = [[
'count' => 0,
'url' => "/i/web/post/_/$item->profile_id/$item->id",
'type' => 'status',
'username' => $item->profile->username,
'caption' => $item->rendered ?? $item->caption,
'caption' => $content,
'thumb' => $url,
'timestamp' => $item->created_at->diffForHumans(),
]];
@ -340,17 +345,21 @@ class SearchController extends Controller
if (isset($remote['type']) && $remote['type'] == 'Note') {
$item = Helpers::statusFetch($tag);
if (! $item) {
return;
}
$media = $item->firstMedia();
$url = null;
if ($media) {
$url = $media->remote_url;
}
$content = $item->caption ? Autolink::create()->autolink($item->caption) : null;
$this->tokens['posts'] = [[
'count' => 0,
'url' => "/i/web/post/_/$item->profile_id/$item->id",
'type' => 'status',
'username' => $item->profile->username,
'caption' => $item->rendered ?? $item->caption,
'caption' => $content,
'thumb' => $url,
'timestamp' => $item->created_at->diffForHumans(),
]];

View file

@ -281,7 +281,7 @@ class StoryApiV1Controller extends Controller
$photo = $request->file('file');
$path = $this->storeMedia($photo, $user);
$story = new Story();
$story = new Story;
$story->duration = $request->input('duration', 3);
$story->profile_id = $user->profile_id;
$story->type = Str::endsWith($photo->getMimeType(), 'mp4') ? 'video' : 'photo';
@ -418,7 +418,6 @@ class StoryApiV1Controller extends Controller
$status->type = 'story:reply';
$status->profile_id = $pid;
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;

View file

@ -54,7 +54,7 @@ class StoryComposeController extends Controller
$photo = $request->file('file');
$path = $this->storePhoto($photo, $user);
$story = new Story();
$story = new Story;
$story->duration = 3;
$story->profile_id = $user->profile_id;
$story->type = Str::endsWith($photo->getMimeType(), 'mp4') ? 'video' : 'photo';
@ -403,7 +403,6 @@ class StoryComposeController extends Controller
$status->profile_id = $pid;
$status->type = 'story:reaction';
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;
@ -477,7 +476,6 @@ class StoryComposeController extends Controller
$status->type = 'story:reply';
$status->profile_id = $pid;
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;

View file

@ -2,35 +2,32 @@
namespace App\Jobs\GroupPipeline;
use App\Notification;
use App\Hashtag;
use App\Mention;
use App\Profile;
use App\Status;
use App\StatusHashtag;
use App\Models\GroupPostHashtag;
use App\Models\GroupPost;
use Cache;
use App\Models\GroupPostHashtag;
use App\Profile;
use App\Services\StatusService;
use App\Status;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\Extractor;
use DB;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Redis;
use App\Services\MediaStorageService;
use App\Services\NotificationService;
use App\Services\StatusService;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\Extractor;
class NewStatusPipeline implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $status;
protected $gp;
protected $tags;
protected $mentions;
public function __construct(Status $status, GroupPost $gp)
@ -50,10 +47,6 @@ class NewStatusPipeline implements ShouldQueue
->autolink($status->caption);
$entities = Extractor::create()->extract($status->caption);
$autolink = str_replace('/discover/tags/', '/groups/' . $status->group_id . '/topics/', $autolink);
$status->rendered = nl2br($autolink);
$status->entities = null;
$status->save();
@ -117,7 +110,7 @@ class NewStatusPipeline implements ShouldQueue
}
DB::transaction(function () use ($status, $mentioned) {
$m = new Mention();
$m = new Mention;
$m->status_id = $status->id;
$m->profile_id = $mentioned->id;
$m->save();

View file

@ -91,11 +91,6 @@ class StatusEntityLexer implements ShouldQueue
public function storeEntities()
{
$this->storeHashtags();
DB::transaction(function () {
$status = $this->status;
$status->rendered = nl2br($this->autolink);
$status->save();
});
}
public function storeHashtags()
@ -146,7 +141,7 @@ class StatusEntityLexer implements ShouldQueue
}
DB::transaction(function () use ($status, $mentioned) {
$m = new Mention();
$m = new Mention;
$m->status_id = $status->id;
$m->profile_id = $mentioned->id;
$m->save();

View file

@ -120,8 +120,7 @@ class StatusRemoteUpdatePipeline implements ShouldQueue
protected function updateImmediateAttributes($status, $activity)
{
if (isset($activity['content'])) {
$status->caption = strip_tags($activity['content']);
$status->rendered = Purify::clean($activity['content']);
$status->caption = strip_tags(Purify::clean($activity['content']));
}
if (isset($activity['sensitive'])) {

View file

@ -3,14 +3,13 @@
namespace App\Services\Status;
use App\Media;
use App\ModLog;
use App\Status;
use App\Models\StatusEdit;
use Purify;
use App\Util\Lexer\Autolink;
use App\ModLog;
use App\Services\MediaService;
use App\Services\MediaStorageService;
use App\Services\StatusService;
use App\Status;
use Purify;
class UpdateStatusService
{
@ -31,7 +30,9 @@ class UpdateStatusService
return;
}
$oids = $status->media()->orderBy('order')->pluck('id')->map(function($m) { return (string) $m; });
$oids = $status->media()->orderBy('order')->pluck('id')->map(function ($m) {
return (string) $m;
});
$nids = collect($attributes['media_ids']);
if ($oids->toArray() === $nids->toArray()) {
@ -64,15 +65,12 @@ class UpdateStatusService
if (isset($attributes['status'])) {
$cleaned = Purify::clean($attributes['status']);
$status->caption = $cleaned;
$status->rendered = nl2br(Autolink::create()->autolink($cleaned));
} else {
$status->caption = null;
$status->rendered = null;
}
if (isset($attributes['sensitive'])) {
if ($status->is_nsfw != (bool) $attributes['sensitive'] &&
(bool) $attributes['sensitive'] == false)
{
(bool) $attributes['sensitive'] == false) {
$exists = ModLog::whereObjectType('App\Status::class')
->whereObjectId($status->id)
->whereAction('admin.status.moderate')
@ -114,7 +112,7 @@ class UpdateStatusService
'spoiler_text' => $status->cw_summary,
'is_nsfw' => $status->is_nsfw,
'ordered_media_attachment_ids' => $status->media()->orderBy('order')->pluck('id')->toArray(),
'created_at' => $status->created_at
'created_at' => $status->created_at,
]);
}
}
@ -131,7 +129,7 @@ class UpdateStatusService
'caption' => $cleaned,
'spoiler_text' => $spoiler_text,
'is_nsfw' => $sensitive,
'ordered_media_attachment_ids' => $mids
'ordered_media_attachment_ids' => $mids,
]);
}
}

View file

@ -694,8 +694,7 @@ class Helpers
$status->url = isset($res['url']) ? $res['url'] : $url;
$status->uri = isset($res['url']) ? $res['url'] : $url;
$status->object_url = $id;
$status->caption = strip_tags($res['content']);
$status->rendered = Purify::clean($res['content']);
$status->caption = strip_tags(Purify::clean($res['content']));
$status->created_at = Carbon::parse($ts)->tz('UTC');
$status->in_reply_to_id = null;
$status->local = false;

View file

@ -438,7 +438,6 @@ class Inbox
$status = new Status;
$status->profile_id = $actor->id;
$status->caption = $msgText;
$status->rendered = $msg;
$status->visibility = 'direct';
$status->scope = 'direct';
$status->url = $activity['id'];
@ -1081,7 +1080,6 @@ class Inbox
$status->uri = $url;
$status->object_url = $url;
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;
@ -1199,7 +1197,6 @@ class Inbox
$status->profile_id = $actorProfile->id;
$status->type = 'story:reply';
$status->caption = $text;
$status->rendered = $text;
$status->url = $url;
$status->uri = $url;
$status->object_url = $url;