kopia lustrzana https://github.com/nextcloud/social
cleaning and renaming
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/282/head
rodzic
76997d0cd5
commit
8174167e48
41
lib/AP.php
41
lib/AP.php
|
@ -32,6 +32,7 @@ namespace OCA\Social;
|
||||||
|
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
|
use OC;
|
||||||
use OCA\Social\Exceptions\ItemUnknownException;
|
use OCA\Social\Exceptions\ItemUnknownException;
|
||||||
use OCA\Social\Exceptions\RedundancyLimitException;
|
use OCA\Social\Exceptions\RedundancyLimitException;
|
||||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||||
|
@ -162,30 +163,30 @@ class AP {
|
||||||
public static function init() {
|
public static function init() {
|
||||||
$ap = new AP();
|
$ap = new AP();
|
||||||
try {
|
try {
|
||||||
$ap->acceptInterface = \OC::$server->query(AcceptInterface::class);
|
$ap->acceptInterface = OC::$server->query(AcceptInterface::class);
|
||||||
$ap->addInterface = \OC::$server->query(AddInterface::class);
|
$ap->addInterface = OC::$server->query(AddInterface::class);
|
||||||
$ap->announceInterface = \OC::$server->query(AnnounceInterface::class);
|
$ap->announceInterface = OC::$server->query(AnnounceInterface::class);
|
||||||
$ap->blockInterface = \OC::$server->query(BlockInterface::class);
|
$ap->blockInterface = OC::$server->query(BlockInterface::class);
|
||||||
$ap->createInterface = \OC::$server->query(CreateInterface::class);
|
$ap->createInterface = OC::$server->query(CreateInterface::class);
|
||||||
$ap->deleteInterface = \OC::$server->query(DeleteInterface::class);
|
$ap->deleteInterface = OC::$server->query(DeleteInterface::class);
|
||||||
$ap->documentInterface = \OC::$server->query(DocumentInterface::class);
|
$ap->documentInterface = OC::$server->query(DocumentInterface::class);
|
||||||
$ap->followInterface = \OC::$server->query(FollowInterface::class);
|
$ap->followInterface = OC::$server->query(FollowInterface::class);
|
||||||
$ap->imageInterface = \OC::$server->query(ImageInterface::class);
|
$ap->imageInterface = OC::$server->query(ImageInterface::class);
|
||||||
$ap->likeInterface = \OC::$server->query(LikeInterface::class);
|
$ap->likeInterface = OC::$server->query(LikeInterface::class);
|
||||||
$ap->noteInterface = \OC::$server->query(NoteInterface::class);
|
$ap->noteInterface = OC::$server->query(NoteInterface::class);
|
||||||
$ap->notificationInterface = \OC::$server->query(SocialAppNotificationInterface::class);
|
$ap->notificationInterface = OC::$server->query(SocialAppNotificationInterface::class);
|
||||||
$ap->personInterface = \OC::$server->query(PersonInterface::class);
|
$ap->personInterface = OC::$server->query(PersonInterface::class);
|
||||||
$ap->rejectInterface = \OC::$server->query(RejectInterface::class);
|
$ap->rejectInterface = OC::$server->query(RejectInterface::class);
|
||||||
$ap->removeInterface = \OC::$server->query(RemoveInterface::class);
|
$ap->removeInterface = OC::$server->query(RemoveInterface::class);
|
||||||
$ap->undoInterface = \OC::$server->query(UndoInterface::class);
|
$ap->undoInterface = OC::$server->query(UndoInterface::class);
|
||||||
$ap->updateInterface = \OC::$server->query(UpdateInterface::class);
|
$ap->updateInterface = OC::$server->query(UpdateInterface::class);
|
||||||
|
|
||||||
$ap->configService = \OC::$server->query(ConfigService::class);
|
$ap->configService = OC::$server->query(ConfigService::class);
|
||||||
|
|
||||||
AP::$activityPub = $ap;
|
AP::$activityPub = $ap;
|
||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
\OC::$server->getLogger()
|
OC::$server->getLogger()
|
||||||
->logException($e);
|
->logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ class LocalController extends Controller {
|
||||||
throw new InvalidResourceException('user have no rights');
|
throw new InvalidResourceException('user have no rights');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->noteService->deleteLocalNote($note);
|
$this->noteService->deleteLocalItem($note);
|
||||||
|
|
||||||
return $this->success();
|
return $this->success();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace OCA\Social\Controller;
|
||||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use OC;
|
||||||
use OC\User\NoUserException;
|
use OC\User\NoUserException;
|
||||||
use OCA\Social\AppInfo\Application;
|
use OCA\Social\AppInfo\Application;
|
||||||
use OCA\Social\Exceptions\AccountAlreadyExistsException;
|
use OCA\Social\Exceptions\AccountAlreadyExistsException;
|
||||||
|
@ -139,7 +140,7 @@ class NavigationController extends Controller {
|
||||||
'public' => false,
|
'public' => false,
|
||||||
'firstrun' => false,
|
'firstrun' => false,
|
||||||
'setup' => false,
|
'setup' => false,
|
||||||
'isAdmin' => \OC::$server->getGroupManager()
|
'isAdmin' => OC::$server->getGroupManager()
|
||||||
->isAdmin($this->userId),
|
->isAdmin($this->userId),
|
||||||
'cliUrl' => $this->getCliUrl()
|
'cliUrl' => $this->getCliUrl()
|
||||||
]
|
]
|
||||||
|
|
|
@ -34,13 +34,9 @@ use daita\MySmallPhpTools\Model\Cache;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use OCA\Social\Exceptions\ItemUnknownException;
|
|
||||||
use OCA\Social\Exceptions\NoteNotFoundException;
|
use OCA\Social\Exceptions\NoteNotFoundException;
|
||||||
use OCA\Social\Exceptions\RedundancyLimitException;
|
|
||||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\ACore;
|
||||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||||
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
|
|
||||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||||
use OCA\Social\Model\ActivityPub\Stream;
|
use OCA\Social\Model\ActivityPub\Stream;
|
||||||
use OCA\Social\Service\ConfigService;
|
use OCA\Social\Service\ConfigService;
|
||||||
|
@ -78,17 +74,56 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
$qb->setValue(
|
$qb->setValue(
|
||||||
'hashtags', $qb->createNamedParameter(json_encode($stream->getHashtags()))
|
'hashtags', $qb->createNamedParameter(json_encode($stream->getHashtags()))
|
||||||
)
|
)
|
||||||
->setValue(
|
->setValue(
|
||||||
'attachments', $qb->createNamedParameter(
|
'attachments', $qb->createNamedParameter(
|
||||||
json_encode($stream->getAttachments(), JSON_UNESCAPED_SLASHES)
|
json_encode($stream->getAttachments(), JSON_UNESCAPED_SLASHES)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->execute();
|
$qb->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Insert a new Note in the database.
|
||||||
|
// *
|
||||||
|
// * @param SocialAppNotification $notification
|
||||||
|
// *
|
||||||
|
// * @throws Exception
|
||||||
|
// */
|
||||||
|
// public function saveNotification(SocialAppNotification $notification) {
|
||||||
|
// $qb = $this->getNotesInsertSql();
|
||||||
|
// $qb->setValue('id', $qb->createNamedParameter($notification->getId()))
|
||||||
|
// ->setValue('type', $qb->createNamedParameter($notification->getType()))
|
||||||
|
// ->setValue('to', $qb->createNamedParameter($notification->getTo()))
|
||||||
|
// ->setValue('to_array', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('cc', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('bcc', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('content', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('summary', $qb->createNamedParameter($notification->getSummary()))
|
||||||
|
// ->setValue('published', $qb->createNamedParameter($notification->getPublished()))
|
||||||
|
// ->setValue(
|
||||||
|
// 'published_time',
|
||||||
|
// $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
||||||
|
// )
|
||||||
|
// ->setValue('attributed_to', $qb->createNamedParameter($notification->getAttributedTo()))
|
||||||
|
// ->setValue('in_reply_to', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('source', $qb->createNamedParameter($notification->getSource()))
|
||||||
|
// ->setValue('instances', $qb->createNamedParameter(''))
|
||||||
|
// ->setValue('local', $qb->createNamedParameter(($notification->isLocal()) ? '1' : '0'))
|
||||||
|
// ->setValue(
|
||||||
|
// 'creation',
|
||||||
|
// $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// $qb->execute();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Stream $stream
|
* @param Stream $stream
|
||||||
* @param Cache $cache
|
* @param Cache $cache
|
||||||
|
@ -106,42 +141,6 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert a new Note in the database.
|
|
||||||
*
|
|
||||||
* @param SocialAppNotification $notification
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function saveNotification(SocialAppNotification $notification) {
|
|
||||||
$qb = $this->getNotesInsertSql();
|
|
||||||
$qb->setValue('id', $qb->createNamedParameter($notification->getId()))
|
|
||||||
->setValue('type', $qb->createNamedParameter($notification->getType()))
|
|
||||||
->setValue('to', $qb->createNamedParameter($notification->getTo()))
|
|
||||||
->setValue('to_array', $qb->createNamedParameter(''))
|
|
||||||
->setValue('cc', $qb->createNamedParameter(''))
|
|
||||||
->setValue('bcc', $qb->createNamedParameter(''))
|
|
||||||
->setValue('content', $qb->createNamedParameter(''))
|
|
||||||
->setValue('summary', $qb->createNamedParameter($notification->getSummary()))
|
|
||||||
->setValue('published', $qb->createNamedParameter($notification->getPublished()))
|
|
||||||
->setValue(
|
|
||||||
'published_time',
|
|
||||||
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
|
||||||
)
|
|
||||||
->setValue('attributed_to', $qb->createNamedParameter($notification->getAttributedTo()))
|
|
||||||
->setValue('in_reply_to', $qb->createNamedParameter(''))
|
|
||||||
->setValue('source', $qb->createNamedParameter($notification->getSource()))
|
|
||||||
->setValue('instances', $qb->createNamedParameter(''))
|
|
||||||
->setValue('local', $qb->createNamedParameter(($notification->isLocal()) ? '1' : '0'))
|
|
||||||
->setValue(
|
|
||||||
'creation',
|
|
||||||
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
|
||||||
);
|
|
||||||
|
|
||||||
$qb->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param bool $asViewer
|
* @param bool $asViewer
|
||||||
|
@ -186,10 +185,8 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
* @param string $id
|
* @param string $id
|
||||||
*
|
*
|
||||||
* @return Stream
|
* @return Stream
|
||||||
* @throws ItemUnknownException
|
|
||||||
* @throws NoteNotFoundException
|
* @throws NoteNotFoundException
|
||||||
* @throws RedundancyLimitException
|
* @throws Exception
|
||||||
* @throws SocialAppConfigException
|
|
||||||
*/
|
*/
|
||||||
public function getNoteByActivityId(string $id): Stream {
|
public function getNoteByActivityId(string $id): Stream {
|
||||||
if ($id === '') {
|
if ($id === '') {
|
||||||
|
@ -219,9 +216,6 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
*
|
*
|
||||||
* @return Stream
|
* @return Stream
|
||||||
* @throws NoteNotFoundException
|
* @throws NoteNotFoundException
|
||||||
* @throws ItemUnknownException
|
|
||||||
* @throws RedundancyLimitException
|
|
||||||
* @throws SocialAppConfigException
|
|
||||||
*/
|
*/
|
||||||
public function getNoteByObjectId(Person $actor, string $type, string $objectId): Stream {
|
public function getNoteByObjectId(Person $actor, string $type, string $objectId): Stream {
|
||||||
if ($objectId === '') {
|
if ($objectId === '') {
|
||||||
|
@ -282,7 +276,7 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
$qb = $this->getNotesSelectSql();
|
$qb = $this->getNotesSelectSql();
|
||||||
|
|
||||||
$this->joinFollowing($qb, $actor);
|
$this->joinFollowing($qb, $actor);
|
||||||
$this->limitToType($qb, Note::TYPE);
|
// $this->limitToType($qb, Note::TYPE);
|
||||||
$this->limitPaginate($qb, $since, $limit);
|
$this->limitPaginate($qb, $since, $limit);
|
||||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||||
$this->leftJoinStreamAction($qb);
|
$this->leftJoinStreamAction($qb);
|
||||||
|
@ -353,7 +347,8 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array {
|
public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array {
|
||||||
$qb = $this->getNotesSelectSql();
|
$qb = $this->getNotesSelectSql();
|
||||||
$this->limitPaginate($qb, $since, $limit);
|
$this->limitPaginate($qb, $since, $limit);
|
||||||
$this->limitToType($qb, Note::TYPE);
|
// $this->limitToType($qb, Note::TYPE);
|
||||||
|
|
||||||
$this->limitToAttributedTo($qb, $actorId);
|
$this->limitToAttributedTo($qb, $actorId);
|
||||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||||
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
||||||
|
@ -389,7 +384,7 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
$qb = $this->getNotesSelectSql();
|
$qb = $this->getNotesSelectSql();
|
||||||
$this->limitPaginate($qb, $since, $limit);
|
$this->limitPaginate($qb, $since, $limit);
|
||||||
|
|
||||||
$this->limitToType($qb, Note::TYPE);
|
// $this->limitToType($qb, Note::TYPE);
|
||||||
$this->limitToRecipient($qb, $actor->getId(), true);
|
$this->limitToRecipient($qb, $actor->getId(), true);
|
||||||
$this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
$this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
||||||
$this->filterToRecipient($qb, $actor->getFollowers());
|
$this->filterToRecipient($qb, $actor->getFollowers());
|
||||||
|
@ -425,10 +420,12 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
): array {
|
): array {
|
||||||
$qb = $this->getNotesSelectSql();
|
$qb = $this->getNotesSelectSql();
|
||||||
$this->limitPaginate($qb, $since, $limit);
|
$this->limitPaginate($qb, $since, $limit);
|
||||||
$this->limitToType($qb, Note::TYPE);
|
// $this->limitToType($qb, Note::TYPE);
|
||||||
|
|
||||||
if ($localOnly) {
|
if ($localOnly) {
|
||||||
$this->limitToLocal($qb, true);
|
$this->limitToLocal($qb, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||||
$this->leftJoinStreamAction($qb);
|
$this->leftJoinStreamAction($qb);
|
||||||
|
|
||||||
|
@ -540,11 +537,14 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
* @param Stream $note
|
* @param Stream $note
|
||||||
*
|
*
|
||||||
* @return IQueryBuilder
|
* @return IQueryBuilder
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function saveStream(Stream $note): IQueryBuilder {
|
public function saveStream(Stream $note): IQueryBuilder {
|
||||||
$dTime = new DateTime();
|
|
||||||
$dTime->setTimestamp($note->getPublishedTime());
|
try {
|
||||||
|
$dTime = new DateTime();
|
||||||
|
$dTime->setTimestamp($note->getPublishedTime());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$cache = '[]';
|
$cache = '[]';
|
||||||
if ($note->gotCache()) {
|
if ($note->gotCache()) {
|
||||||
|
@ -579,9 +579,6 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
->setValue('content', $qb->createNamedParameter($note->getContent()))
|
->setValue('content', $qb->createNamedParameter($note->getContent()))
|
||||||
->setValue('summary', $qb->createNamedParameter($note->getSummary()))
|
->setValue('summary', $qb->createNamedParameter($note->getSummary()))
|
||||||
->setValue('published', $qb->createNamedParameter($note->getPublished()))
|
->setValue('published', $qb->createNamedParameter($note->getPublished()))
|
||||||
->setValue(
|
|
||||||
'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)
|
|
||||||
)
|
|
||||||
->setValue('attributed_to', $qb->createNamedParameter($attributedTo))
|
->setValue('attributed_to', $qb->createNamedParameter($attributedTo))
|
||||||
->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo()))
|
->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo()))
|
||||||
->setValue('source', $qb->createNamedParameter($note->getSource()))
|
->setValue('source', $qb->createNamedParameter($note->getSource()))
|
||||||
|
@ -592,11 +589,20 @@ class NotesRequest extends NotesRequestBuilder {
|
||||||
json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES)
|
json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setValue('local', $qb->createNamedParameter(($note->isLocal()) ? '1' : '0'))
|
->setValue('local', $qb->createNamedParameter(($note->isLocal()) ? '1' : '0'));
|
||||||
->setValue(
|
|
||||||
'creation',
|
try {
|
||||||
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
$dTime = new DateTime();
|
||||||
);
|
$dTime->setTimestamp($note->getPublishedTime());
|
||||||
|
$qb->setValue(
|
||||||
|
'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)
|
||||||
|
)
|
||||||
|
->setValue(
|
||||||
|
'creation',
|
||||||
|
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$this->generatePrimaryKey($qb, $note->getId());
|
$this->generatePrimaryKey($qb, $note->getId());
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ namespace OCA\Social\Db;
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Exception;
|
|
||||||
use OCA\Social\Exceptions\InvalidResourceException;
|
use OCA\Social\Exceptions\InvalidResourceException;
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\ACore;
|
||||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||||
|
@ -362,7 +361,6 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return Stream
|
* @return Stream
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
protected function parseNotesSelectSql($data): Stream {
|
protected function parseNotesSelectSql($data): Stream {
|
||||||
$item = new Stream();
|
$item = new Stream();
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace OCA\Social\Exceptions;
|
namespace OCA\Social\Exceptions;
|
||||||
|
|
||||||
class ActivityCantBeVerifiedException extends \Exception {
|
use Exception;
|
||||||
|
|
||||||
|
class ActivityCantBeVerifiedException extends Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->miscService->log('Generating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1);
|
$this->miscService->log('Generating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1);
|
||||||
$this->notesRequest->saveNotification($notification);
|
$this->notesRequest->save($notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,12 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Model\ActivityPub\Internal;
|
namespace OCA\Social\Model\ActivityPub\Internal;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\Stream;
|
||||||
|
|
||||||
|
|
||||||
class SocialAppNotification extends ACore implements JsonSerializable {
|
class SocialAppNotification extends Stream implements JsonSerializable {
|
||||||
|
|
||||||
|
|
||||||
const TYPE = 'SocialAppNotification';
|
const TYPE = 'SocialAppNotification';
|
||||||
|
@ -54,6 +55,8 @@ class SocialAppNotification extends ACore implements JsonSerializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function import(array $data) {
|
public function import(array $data) {
|
||||||
parent::import($data);
|
parent::import($data);
|
||||||
|
@ -62,6 +65,8 @@ class SocialAppNotification extends ACore implements JsonSerializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function importFromDatabase(array $data) {
|
public function importFromDatabase(array $data) {
|
||||||
parent::importFromDatabase($data);
|
parent::importFromDatabase($data);
|
||||||
|
|
|
@ -307,17 +307,18 @@ class Stream extends ACore implements JsonSerializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function importFromDatabase(array $data) {
|
public function importFromDatabase(array $data) {
|
||||||
parent::importFromDatabase($data);
|
parent::importFromDatabase($data);
|
||||||
|
|
||||||
$dTime = new DateTime($this->get('published_time', $data, 'yesterday'));
|
try {
|
||||||
|
$dTime = new DateTime($this->get('published_time', $data, 'yesterday'));
|
||||||
|
$this->setPublishedTime($dTime->getTimestamp());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$this->setActivityId($this->validate(self::AS_ID, 'activity_id', $data, ''));
|
$this->setActivityId($this->validate(self::AS_ID, 'activity_id', $data, ''));
|
||||||
$this->setContent($this->validate(self::AS_STRING, 'content', $data, ''));
|
$this->setContent($this->validate(self::AS_STRING, 'content', $data, ''));
|
||||||
$this->setPublishedTime($dTime->getTimestamp());
|
|
||||||
$this->setObjectId($this->validate(self::AS_ID, 'object_id', $data, ''));
|
$this->setObjectId($this->validate(self::AS_ID, 'object_id', $data, ''));
|
||||||
$this->setAttributedTo($this->validate(self::AS_ID, 'attributed_to', $data, ''));
|
$this->setAttributedTo($this->validate(self::AS_ID, 'attributed_to', $data, ''));
|
||||||
$this->setInReplyTo($this->validate(self::AS_ID, 'in_reply_to', $data));
|
$this->setInReplyTo($this->validate(self::AS_ID, 'in_reply_to', $data));
|
||||||
|
|
|
@ -26,6 +26,8 @@ namespace OCA\Social\Service;
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||||
use daita\MySmallPhpTools\Traits\TStringTools;
|
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||||
|
use Exception;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use OCA\Social\Db\FollowsRequest;
|
use OCA\Social\Db\FollowsRequest;
|
||||||
use OCA\Social\Model\ActivityPub\Object\Follow;
|
use OCA\Social\Model\ActivityPub\Object\Follow;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
|
@ -175,8 +177,8 @@ class CheckService {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
} catch (ClientException $e) {
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -312,18 +312,18 @@ class NoteService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Note $note
|
* @param Stream $item
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function deleteLocalNote(Note $note) {
|
public function deleteLocalItem(Stream $item) {
|
||||||
if (!$note->isLocal()) {
|
if (!$item->isLocal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$note->setActorId($note->getAttributedTo());
|
$item->setActorId($item->getAttributedTo());
|
||||||
$this->activityService->deleteActivity($note);
|
$this->activityService->deleteActivity($item);
|
||||||
$this->notesRequest->deleteNoteById($note->getId());
|
$this->notesRequest->deleteNoteById($item->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace OCA\Social;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use OC;
|
||||||
use OCA\Social\Service\CacheActorService;
|
use OCA\Social\Service\CacheActorService;
|
||||||
use OCA\Social\Service\ConfigService;
|
use OCA\Social\Service\ConfigService;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ if (!array_key_exists('resource', $_GET)) {
|
||||||
|
|
||||||
$subject = $_GET['resource'];
|
$subject = $_GET['resource'];
|
||||||
|
|
||||||
$urlGenerator = \OC::$server->getURLGenerator();
|
$urlGenerator = OC::$server->getURLGenerator();
|
||||||
|
|
||||||
list($type, $account) = explode(':', $subject, 2);
|
list($type, $account) = explode(':', $subject, 2);
|
||||||
if ($type !== 'acct') {
|
if ($type !== 'acct') {
|
||||||
|
@ -55,8 +56,8 @@ if ($type !== 'acct') {
|
||||||
list($username, $instance) = explode('@', $account);
|
list($username, $instance) = explode('@', $account);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cacheActorService = \OC::$server->query(CacheActorService::class);
|
$cacheActorService = OC::$server->query(CacheActorService::class);
|
||||||
$configService = \OC::$server->query(ConfigService::class);
|
$configService = OC::$server->query(ConfigService::class);
|
||||||
|
|
||||||
if ($configService->getCloudAddress(true) !== $instance) {
|
if ($configService->getCloudAddress(true) !== $instance) {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
require_once __DIR__ . '/../../../tests/bootstrap.php';
|
require_once __DIR__ . '/../../../tests/bootstrap.php';
|
||||||
require_once __DIR__.'/../vendor/autoload.php';
|
require_once __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
\OC_App::loadApp('social');
|
OC_App::loadApp('social');
|
||||||
OC_Hook::clear();
|
OC_Hook::clear();
|
||||||
|
|
Ładowanie…
Reference in New Issue