kopia lustrzana https://github.com/nextcloud/social
renaming NoteService -> StreamService
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/678/head
rodzic
53ef10e50f
commit
708fef7c66
|
@ -48,7 +48,7 @@ use OCA\Social\Service\FollowService;
|
|||
use OCA\Social\Service\HashtagService;
|
||||
use OCA\Social\Service\LikeService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use OCA\Social\Service\NoteService;
|
||||
use OCA\Social\Service\StreamService;
|
||||
use OCA\Social\Service\PostService;
|
||||
use OCA\Social\Service\SearchService;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
@ -92,8 +92,8 @@ class LocalController extends Controller {
|
|||
/** @var PostService */
|
||||
private $postService;
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
/** @var StreamService */
|
||||
private $streamService;
|
||||
|
||||
/** @var SearchService */
|
||||
private $searchService;
|
||||
|
@ -122,7 +122,7 @@ class LocalController extends Controller {
|
|||
* @param HashtagService $hashtagService
|
||||
* @param FollowService $followService
|
||||
* @param PostService $postService
|
||||
* @param NoteService $noteService
|
||||
* @param StreamService $streamService
|
||||
* @param SearchService $searchService
|
||||
* @param BoostService $boostService
|
||||
* @param LikeService $likeService
|
||||
|
@ -133,7 +133,7 @@ class LocalController extends Controller {
|
|||
IRequest $request, $userId, AccountService $accountService,
|
||||
CacheActorService $cacheActorService, HashtagService $hashtagService,
|
||||
FollowService $followService,
|
||||
PostService $postService, NoteService $noteService, SearchService $searchService,
|
||||
PostService $postService, StreamService $streamService, SearchService $searchService,
|
||||
BoostService $boostService, LikeService $likeService, DocumentService $documentService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
|
@ -143,7 +143,7 @@ class LocalController extends Controller {
|
|||
$this->cacheActorService = $cacheActorService;
|
||||
$this->hashtagService = $hashtagService;
|
||||
$this->accountService = $accountService;
|
||||
$this->noteService = $noteService;
|
||||
$this->streamService = $streamService;
|
||||
$this->searchService = $searchService;
|
||||
$this->postService = $postService;
|
||||
$this->followService = $followService;
|
||||
|
@ -202,7 +202,7 @@ class LocalController extends Controller {
|
|||
try {
|
||||
$this->initViewer(true);
|
||||
|
||||
return $this->directSuccess($this->noteService->getNoteById($id, true));
|
||||
return $this->directSuccess($this->streamService->getStreamById($id, true));
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
|
@ -220,13 +220,13 @@ class LocalController extends Controller {
|
|||
*/
|
||||
public function postDelete(string $id): DataResponse {
|
||||
try {
|
||||
$note = $this->noteService->getNoteById($id);
|
||||
$note = $this->streamService->getStreamById($id);
|
||||
$actor = $this->accountService->getActorFromUserId($this->userId);
|
||||
if ($note->getAttributedTo() !== $actor->getId()) {
|
||||
throw new InvalidResourceException('user have no rights');
|
||||
}
|
||||
|
||||
$this->noteService->deleteLocalItem($note, Note::TYPE);
|
||||
$this->streamService->deleteLocalItem($note, Note::TYPE);
|
||||
|
||||
return $this->success();
|
||||
} catch (Exception $e) {
|
||||
|
@ -351,7 +351,7 @@ class LocalController extends Controller {
|
|||
public function streamHome($since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamHome($this->viewer, $since, $limit);
|
||||
$posts = $this->streamService->getStreamHome($this->viewer, $since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -372,7 +372,7 @@ class LocalController extends Controller {
|
|||
public function streamNotifications($since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamNotifications($this->viewer, $since, $limit);
|
||||
$posts = $this->streamService->getStreamNotifications($this->viewer, $since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -396,7 +396,7 @@ class LocalController extends Controller {
|
|||
$this->initViewer();
|
||||
|
||||
$account = $this->cacheActorService->getFromLocalAccount($username);
|
||||
$posts = $this->noteService->getStreamAccount($account->getId(), $since, $limit);
|
||||
$posts = $this->streamService->getStreamAccount($account->getId(), $since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -417,7 +417,7 @@ class LocalController extends Controller {
|
|||
public function streamDirect(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamDirect($this->viewer, $since, $limit);
|
||||
$posts = $this->streamService->getStreamDirect($this->viewer, $since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -440,7 +440,7 @@ class LocalController extends Controller {
|
|||
public function streamTimeline(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamLocalTimeline($since, $limit);
|
||||
$posts = $this->streamService->getStreamLocalTimeline($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -463,7 +463,7 @@ class LocalController extends Controller {
|
|||
public function streamTag(string $hashtag, int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamLocalTag($this->viewer, $hashtag, $since, $limit);
|
||||
$posts = $this->streamService->getStreamLocalTag($this->viewer, $hashtag, $since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -485,7 +485,7 @@ class LocalController extends Controller {
|
|||
public function streamFederated(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamGlobalTimeline($since, $limit);
|
||||
$posts = $this->streamService->getStreamGlobalTimeline($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -507,7 +507,7 @@ class LocalController extends Controller {
|
|||
public function streamLiked(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->noteService->getStreamLiked($since, $limit);
|
||||
$posts = $this->streamService->getStreamLiked($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -886,7 +886,7 @@ class LocalController extends Controller {
|
|||
try {
|
||||
$this->viewer = $this->accountService->getActorFromUserId($this->userId, true);
|
||||
|
||||
$this->noteService->setViewer($this->viewer);
|
||||
$this->streamService->setViewer($this->viewer);
|
||||
$this->followService->setViewer($this->viewer);
|
||||
$this->cacheActorService->setViewer($this->viewer);
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -39,7 +39,7 @@ use OCA\Social\Service\SignatureService;
|
|||
|
||||
|
||||
/**
|
||||
* Class InstancePath
|
||||
* Class LinkedDataSignature
|
||||
*
|
||||
* @package OCA\Social\Model
|
||||
*/
|
||||
|
|
|
@ -63,8 +63,8 @@ class LikeService {
|
|||
/** @var StreamRequest */
|
||||
private $streamRequest;
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
/** @var StreamService */
|
||||
private $streamService;
|
||||
|
||||
/** @var SignatureService */
|
||||
private $signatureService;
|
||||
|
@ -86,7 +86,7 @@ class LikeService {
|
|||
* LikeService constructor.
|
||||
*
|
||||
* @param StreamRequest $streamRequest
|
||||
* @param NoteService $noteService
|
||||
* @param StreamService $streamService
|
||||
* @param SignatureService $signatureService
|
||||
* @param ActivityService $activityService
|
||||
* @param StreamActionService $streamActionService
|
||||
|
@ -94,12 +94,12 @@ class LikeService {
|
|||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
StreamRequest $streamRequest, NoteService $noteService, SignatureService $signatureService,
|
||||
StreamRequest $streamRequest, StreamService $streamService, SignatureService $signatureService,
|
||||
ActivityService $activityService, StreamActionService $streamActionService,
|
||||
StreamQueueService $streamQueueService, MiscService $miscService
|
||||
) {
|
||||
$this->streamRequest = $streamRequest;
|
||||
$this->noteService = $noteService;
|
||||
$this->streamService = $streamService;
|
||||
$this->signatureService = $signatureService;
|
||||
$this->activityService = $activityService;
|
||||
$this->streamActionService = $streamActionService;
|
||||
|
@ -124,7 +124,7 @@ class LikeService {
|
|||
$like->setId($actor->getId() . '#like/' . $this->uuid(8));
|
||||
$like->setActor($actor);
|
||||
|
||||
$note = $this->noteService->getNoteById($postId, true);
|
||||
$note = $this->streamService->getStreamById($postId, true);
|
||||
if ($note->getType() !== Note::TYPE) {
|
||||
throw new StreamNotFoundException('Stream is not a Note');
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class LikeService {
|
|||
$undo = new Undo();
|
||||
$undo->setActor($actor);
|
||||
|
||||
$note = $this->noteService->getNoteById($postId, true);
|
||||
$note = $this->streamService->getStreamById($postId, true);
|
||||
if ($note->getType() !== Note::TYPE) {
|
||||
throw new StreamNotFoundException('Stream is not a Note');
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ use OCA\Social\Model\Post;
|
|||
class PostService {
|
||||
|
||||
|
||||
/** @var NoteService */
|
||||
private $noteService;
|
||||
/** @var StreamService */
|
||||
private $streamService;
|
||||
|
||||
/** @var AccountService */
|
||||
private $accountService;
|
||||
|
@ -68,17 +68,17 @@ class PostService {
|
|||
/**
|
||||
* PostService constructor.
|
||||
*
|
||||
* @param NoteService $noteService
|
||||
* @param StreamService $streamService
|
||||
* @param AccountService $accountService
|
||||
* @param ActivityService $activityService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
NoteService $noteService, AccountService $accountService, ActivityService $activityService,
|
||||
StreamService $streamService, AccountService $accountService, ActivityService $activityService,
|
||||
ConfigService $configService, MiscService $miscService
|
||||
) {
|
||||
$this->noteService = $noteService;
|
||||
$this->streamService = $streamService;
|
||||
$this->accountService = $accountService;
|
||||
$this->activityService = $activityService;
|
||||
$this->configService = $configService;
|
||||
|
@ -107,16 +107,16 @@ class PostService {
|
|||
public function createPost(Post $post, &$token = ''): ACore {
|
||||
$note = new Note();
|
||||
$actor = $post->getActor();
|
||||
$this->noteService->assignItem($note, $actor, $post->getType());
|
||||
$this->streamService->assignItem($note, $actor, $post->getType());
|
||||
|
||||
$note->setAttributedTo($actor->getId());
|
||||
// $this->configService->getSocialUrl() . '@' . $actor->getPreferredUsername()
|
||||
|
||||
$note->setContent(htmlentities($post->getContent(), ENT_QUOTES));
|
||||
|
||||
$this->noteService->replyTo($note, $post->getReplyTo());
|
||||
$this->noteService->addRecipients($note, $post->getType(), $post->getTo());
|
||||
$this->noteService->addHashtags($note, $post->getHashtags());
|
||||
$this->streamService->replyTo($note, $post->getReplyTo());
|
||||
$this->streamService->addRecipients($note, $post->getType(), $post->getTo());
|
||||
$this->streamService->addHashtags($note, $post->getHashtags());
|
||||
|
||||
$token = $this->activityService->createActivity($actor, $note, $activity);
|
||||
$this->accountService->cacheLocalActorDetailCount($actor);
|
||||
|
|
|
@ -51,7 +51,8 @@ use OCA\Social\Model\ActivityPub\Object\Note;
|
|||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
|
||||
class NoteService {
|
||||
|
||||
class StreamService {
|
||||
|
||||
|
||||
/** @var StreamRequest */
|
||||
|
@ -207,6 +208,32 @@ class NoteService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $stream
|
||||
*/
|
||||
public function detectType(Stream $stream) {
|
||||
if (in_array(ACore::CONTEXT_PUBLIC, $stream->getToAll())) {
|
||||
$stream->setType(Stream::TYPE_PUBLIC);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array(ACore::CONTEXT_PUBLIC, $stream->getCcArray())) {
|
||||
$stream->setType(Stream::TYPE_UNLISTED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$actor = $this->cacheActorService->getFromId($stream->getAttributedTo());
|
||||
echo json_encode($actor) . "\n";
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Stream $stream
|
||||
* @param string $type
|
||||
|
@ -295,16 +322,17 @@ class NoteService {
|
|||
*
|
||||
* @throws InvalidOriginException
|
||||
* @throws InvalidResourceException
|
||||
* @throws ItemUnknownException
|
||||
* @throws MalformedArrayException
|
||||
* @throws StreamNotFoundException
|
||||
* @throws RedundancyLimitException
|
||||
* @throws RequestContentException
|
||||
* @throws RequestNetworkException
|
||||
* @throws RequestResultNotJsonException
|
||||
* @throws RequestResultSizeException
|
||||
* @throws RequestServerException
|
||||
* @throws SocialAppConfigException
|
||||
* @throws ItemUnknownException
|
||||
* @throws RequestResultNotJsonException
|
||||
* @throws StreamNotFoundException
|
||||
* @throws UnauthorizedFediverseException
|
||||
*/
|
||||
public function replyTo(Note $note, string $replyTo) {
|
||||
if ($replyTo === '') {
|
||||
|
@ -346,7 +374,7 @@ class NoteService {
|
|||
* @return Stream
|
||||
* @throws StreamNotFoundException
|
||||
*/
|
||||
public function getNoteById(string $id, bool $asViewer = false): Stream {
|
||||
public function getStreamById(string $id, bool $asViewer = false): Stream {
|
||||
return $this->streamRequest->getStreamById($id, $asViewer);
|
||||
}
|
||||
|
Ładowanie…
Reference in New Issue