kopia lustrzana https://github.com/pixelfed/pixelfed
				
				
				
			Add StatusMentionService, fixes #3026
							rodzic
							
								
									89d62176cb
								
							
						
					
					
						commit
						e5387d6742
					
				| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Services;
 | 
			
		||||
 | 
			
		||||
use Illuminate\Support\Facades\Cache;
 | 
			
		||||
use App\Mention;
 | 
			
		||||
use Illuminate\Support\Str;
 | 
			
		||||
 | 
			
		||||
class StatusMentionService
 | 
			
		||||
{
 | 
			
		||||
	public static function get($id)
 | 
			
		||||
	{
 | 
			
		||||
		return Mention::whereStatusId($id)
 | 
			
		||||
			->get()
 | 
			
		||||
			->map(function($mention) {
 | 
			
		||||
				return AccountService::get($mention->profile_id);
 | 
			
		||||
			})->filter(function($mention) {
 | 
			
		||||
				return $mention;
 | 
			
		||||
			})
 | 
			
		||||
			->values()
 | 
			
		||||
			->toArray();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ use App\Services\MediaService;
 | 
			
		|||
use App\Services\MediaTagService;
 | 
			
		||||
use App\Services\StatusHashtagService;
 | 
			
		||||
use App\Services\StatusLabelService;
 | 
			
		||||
use App\Services\StatusMentionService;
 | 
			
		||||
use App\Services\ProfileService;
 | 
			
		||||
use App\Services\PollService;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +36,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
 | 
			
		|||
			'created_at'                => $status->created_at->format('c'),
 | 
			
		||||
			'emojis'                    => [],
 | 
			
		||||
			'reblogs_count'             => 0,
 | 
			
		||||
			'favourites_count'          => 0,
 | 
			
		||||
			'favourites_count'          => $status->likes_count ?? 0,
 | 
			
		||||
			'reblogged'                 => null,
 | 
			
		||||
			'favourited'                => null,
 | 
			
		||||
			'muted'                     => null,
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +49,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
 | 
			
		|||
			 ],
 | 
			
		||||
			'language'                  => null,
 | 
			
		||||
			'pinned'                    => null,
 | 
			
		||||
			'mentions'                  => [],
 | 
			
		||||
			'mentions'                  => StatusMentionService::get($status->id),
 | 
			
		||||
			'tags'                      => [],
 | 
			
		||||
			'pf_type'                   => $status->type ?? $status->setType(),
 | 
			
		||||
			'reply_count'               => (int) $status->reply_count,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ use App\Services\MediaService;
 | 
			
		|||
use App\Services\MediaTagService;
 | 
			
		||||
use App\Services\StatusHashtagService;
 | 
			
		||||
use App\Services\StatusLabelService;
 | 
			
		||||
use App\Services\StatusMentionService;
 | 
			
		||||
use App\Services\ProfileService;
 | 
			
		||||
use Illuminate\Support\Str;
 | 
			
		||||
use App\Services\PollService;
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +38,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
 | 
			
		|||
			'created_at'                => $status->created_at->format('c'),
 | 
			
		||||
			'emojis'                    => [],
 | 
			
		||||
			'reblogs_count'             => 0,
 | 
			
		||||
			'favourites_count'          => 0,
 | 
			
		||||
			'favourites_count'          => $status->likes_count ?? 0,
 | 
			
		||||
			'reblogged'                 => $status->shared(),
 | 
			
		||||
			'favourited'                => $status->liked(),
 | 
			
		||||
			'muted'                     => null,
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +51,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
 | 
			
		|||
			 ],
 | 
			
		||||
			'language'                  => null,
 | 
			
		||||
			'pinned'                    => null,
 | 
			
		||||
			'mentions'                  => [],
 | 
			
		||||
			'mentions'                  => StatusMentionService::get($status->id),
 | 
			
		||||
			'tags'                      => [],
 | 
			
		||||
			'pf_type'                   => $status->type ?? $status->setType(),
 | 
			
		||||
			'reply_count'               => (int) $status->reply_count,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue