2018-09-28 11:41:24 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Nextcloud - Social Support
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
|
|
|
* @author Maxence Lange <maxence@artificial-owl.com>
|
|
|
|
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Social\Db;
|
|
|
|
|
|
|
|
|
2019-01-24 11:26:44 +00:00
|
|
|
use daita\MySmallPhpTools\Model\Cache;
|
2018-11-16 10:47:59 +00:00
|
|
|
use DateTime;
|
2019-01-18 15:45:56 +00:00
|
|
|
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
2018-11-20 12:47:14 +00:00
|
|
|
use OCA\Social\Exceptions\NoteNotFoundException;
|
2018-12-19 19:55:54 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\ACore;
|
2018-12-13 09:40:27 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
2018-12-20 09:54:54 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Object\Note;
|
2019-01-24 11:26:44 +00:00
|
|
|
use OCA\Social\Model\ActivityPub\Stream;
|
2018-09-28 11:41:24 +00:00
|
|
|
use OCA\Social\Service\ConfigService;
|
|
|
|
use OCA\Social\Service\MiscService;
|
2018-11-13 14:20:43 +00:00
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
2018-09-28 11:41:24 +00:00
|
|
|
use OCP\IDBConnection;
|
|
|
|
|
|
|
|
class NotesRequest extends NotesRequestBuilder {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-10-01 12:14:23 +00:00
|
|
|
* NotesRequest constructor.
|
2018-09-28 11:41:24 +00:00
|
|
|
*
|
|
|
|
* @param IDBConnection $connection
|
|
|
|
* @param ConfigService $configService
|
|
|
|
* @param MiscService $miscService
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
IDBConnection $connection, ConfigService $configService, MiscService $miscService
|
|
|
|
) {
|
|
|
|
parent::__construct($connection, $configService, $miscService);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-02-23 00:04:00 +00:00
|
|
|
* @param Stream $stream
|
2018-09-28 11:41:24 +00:00
|
|
|
*/
|
2019-02-23 00:04:00 +00:00
|
|
|
public function save(Stream $stream) {
|
|
|
|
$qb = $this->saveStream($stream);
|
|
|
|
|
|
|
|
if ($stream->getType() === Note::TYPE) {
|
|
|
|
/** @var Note $stream */
|
|
|
|
$qb->setValue(
|
|
|
|
'hashtags', $qb->createNamedParameter(json_encode($stream->getHashtags()))
|
2019-03-05 15:11:16 +00:00
|
|
|
)
|
|
|
|
->setValue(
|
2019-01-18 15:45:56 +00:00
|
|
|
'attachments', $qb->createNamedParameter(
|
|
|
|
json_encode($note->getAttachments(), JSON_UNESCAPED_SLASHES)
|
|
|
|
)
|
2018-11-20 12:47:14 +00:00
|
|
|
);
|
2019-01-24 11:26:44 +00:00
|
|
|
}
|
|
|
|
|
2018-11-20 12:47:14 +00:00
|
|
|
$qb->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-24 11:26:44 +00:00
|
|
|
/**
|
|
|
|
* @param Stream $stream
|
|
|
|
* @param Cache $cache
|
|
|
|
*/
|
|
|
|
public function updateCache(Stream $stream, Cache $cache) {
|
|
|
|
$qb = $this->getNotesUpdateSql();
|
|
|
|
$qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES)));
|
|
|
|
|
|
|
|
$this->limitToIdString($qb, $stream->getId());
|
2018-11-20 12:47:14 +00:00
|
|
|
|
2019-01-18 15:45:56 +00:00
|
|
|
try {
|
|
|
|
$qb->execute();
|
|
|
|
} catch (UniqueConstraintViolationException $e) {
|
|
|
|
}
|
2018-11-20 12:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $id
|
2019-02-23 00:04:00 +00:00
|
|
|
* @param bool $asViewer
|
2018-11-20 12:47:14 +00:00
|
|
|
*
|
|
|
|
* @return Note
|
|
|
|
* @throws NoteNotFoundException
|
|
|
|
*/
|
2019-02-23 00:04:00 +00:00
|
|
|
public function getNoteById(string $id, bool $asViewer = false): Note {
|
2018-11-20 12:47:14 +00:00
|
|
|
if ($id === '') {
|
|
|
|
throw new NoteNotFoundException();
|
|
|
|
};
|
|
|
|
|
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
$this->limitToIdString($qb, $id);
|
|
|
|
|
2019-02-23 00:04:00 +00:00
|
|
|
if ($asViewer) {
|
|
|
|
$this->limitToViewer($qb);
|
|
|
|
}
|
|
|
|
|
2018-11-20 12:47:14 +00:00
|
|
|
$cursor = $qb->execute();
|
|
|
|
$data = $cursor->fetch();
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
if ($data === false) {
|
2018-12-19 01:13:33 +00:00
|
|
|
throw new NoteNotFoundException('Post not found');
|
2018-09-28 11:41:24 +00:00
|
|
|
}
|
2018-11-20 12:47:14 +00:00
|
|
|
|
|
|
|
return $this->parseNotesSelectSql($data);
|
2018-09-28 11:41:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-12 22:55:39 +00:00
|
|
|
|
2019-01-24 11:27:36 +00:00
|
|
|
/**
|
|
|
|
* @param string $id
|
|
|
|
*
|
|
|
|
* @return Note
|
|
|
|
* @throws NoteNotFoundException
|
|
|
|
*/
|
|
|
|
public function getNoteByActivityId(string $id): Note {
|
|
|
|
if ($id === '') {
|
|
|
|
throw new NoteNotFoundException();
|
|
|
|
};
|
|
|
|
|
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
$this->limitToActivityId($qb, $id);
|
|
|
|
|
2018-11-20 12:47:14 +00:00
|
|
|
$cursor = $qb->execute();
|
|
|
|
$data = $cursor->fetch();
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
if ($data === false) {
|
2018-12-19 01:13:33 +00:00
|
|
|
throw new NoteNotFoundException('Post not found');
|
2018-09-28 11:41:24 +00:00
|
|
|
}
|
2018-11-20 12:47:14 +00:00
|
|
|
|
|
|
|
return $this->parseNotesSelectSql($data);
|
2018-09-28 11:41:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-12 22:55:39 +00:00
|
|
|
|
2018-11-29 18:28:37 +00:00
|
|
|
/**
|
|
|
|
* @param string $actorId
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function countNotesFromActorId(string $actorId): int {
|
|
|
|
$qb = $this->countNotesSelectSql();
|
|
|
|
$this->limitToAttributedTo($qb, $actorId);
|
|
|
|
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
$data = $cursor->fetch();
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $this->getInt('count', $data, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-22 11:46:29 +00:00
|
|
|
/**
|
2018-12-04 23:49:17 +00:00
|
|
|
* Should returns:
|
|
|
|
* * Own posts,
|
|
|
|
* * Followed accounts
|
|
|
|
*
|
2018-12-06 19:18:12 +00:00
|
|
|
* @param Person $actor
|
2018-11-28 10:39:31 +00:00
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
2018-11-22 11:46:29 +00:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-12-06 19:18:12 +00:00
|
|
|
public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array {
|
2018-11-22 11:46:29 +00:00
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
|
2018-12-06 19:18:12 +00:00
|
|
|
$this->joinFollowing($qb, $actor);
|
2018-11-22 15:11:46 +00:00
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
2018-11-28 10:16:20 +00:00
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
2018-11-22 11:46:29 +00:00
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-19 01:13:33 +00:00
|
|
|
/**
|
|
|
|
* Should returns:
|
|
|
|
* * Public/Unlisted/Followers-only post where current $actor is tagged,
|
|
|
|
* - Events: (not yet)
|
|
|
|
* - people liking or re-posting your posts (not yet)
|
|
|
|
* - someone wants to follow you (not yet)
|
|
|
|
* - someone is following you (not yet)
|
|
|
|
*
|
|
|
|
* @param Person $actor
|
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array {
|
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
|
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
|
|
|
$this->limitToRecipient($qb, $actor->getId(), false);
|
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-12 22:55:39 +00:00
|
|
|
/**
|
2018-12-05 00:01:07 +00:00
|
|
|
* Should returns:
|
|
|
|
* * public message from actorId.
|
2018-12-19 01:13:33 +00:00
|
|
|
* - to followers-only if follower is logged. (not yet (check ?))
|
2018-12-05 00:01:07 +00:00
|
|
|
*
|
|
|
|
* @param string $actorId
|
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array {
|
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
|
|
|
$this->limitToAttributedTo($qb, $actorId);
|
2018-12-05 09:49:44 +00:00
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
2018-12-19 19:55:54 +00:00
|
|
|
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
2018-12-05 00:01:07 +00:00
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should returns:
|
2018-12-04 23:49:17 +00:00
|
|
|
* * Private message.
|
2018-12-19 01:13:33 +00:00
|
|
|
* - group messages. (not yet)
|
2018-12-05 00:01:07 +00:00
|
|
|
*
|
2018-12-06 19:18:12 +00:00
|
|
|
* @param Person $actor
|
2018-11-14 12:04:33 +00:00
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
2018-11-12 22:55:39 +00:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-12-06 19:18:12 +00:00
|
|
|
public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array {
|
2018-11-12 22:55:39 +00:00
|
|
|
$qb = $this->getNotesSelectSql();
|
2018-11-13 14:20:43 +00:00
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
2018-12-06 19:18:12 +00:00
|
|
|
|
|
|
|
$this->limitToRecipient($qb, $actor->getId(), true);
|
2018-12-19 19:55:54 +00:00
|
|
|
$this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC);
|
2018-12-06 19:18:12 +00:00
|
|
|
$this->filterToRecipient($qb, $actor->getFollowers());
|
|
|
|
|
2018-11-14 12:04:33 +00:00
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
2018-11-12 22:55:39 +00:00
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
2018-11-22 11:46:29 +00:00
|
|
|
|
2018-11-12 22:55:39 +00:00
|
|
|
/**
|
2018-12-04 23:49:17 +00:00
|
|
|
* Should returns:
|
2018-12-19 01:13:33 +00:00
|
|
|
* * All local public/federated posts
|
2018-12-04 23:49:17 +00:00
|
|
|
*
|
2018-11-28 10:39:31 +00:00
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
2018-12-04 23:49:17 +00:00
|
|
|
* @param bool $localOnly
|
2018-11-12 22:55:39 +00:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-12-04 23:49:17 +00:00
|
|
|
public function getStreamTimeline(int $since = 0, int $limit = 5, bool $localOnly = true
|
2018-11-28 10:39:31 +00:00
|
|
|
): array {
|
2018-11-12 22:55:39 +00:00
|
|
|
$qb = $this->getNotesSelectSql();
|
2018-11-22 15:11:46 +00:00
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
2018-12-04 23:49:17 +00:00
|
|
|
if ($localOnly) {
|
|
|
|
$this->limitToLocal($qb, true);
|
|
|
|
}
|
2018-11-14 12:04:33 +00:00
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
2018-12-06 19:22:33 +00:00
|
|
|
// TODO: to: = real public, cc: = unlisted !?
|
2018-12-19 19:55:54 +00:00
|
|
|
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']);
|
2018-11-12 22:55:39 +00:00
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-04 19:42:58 +00:00
|
|
|
/**
|
|
|
|
* Should returns:
|
|
|
|
* - All public post related to a tag (not yet)
|
|
|
|
* - direct message related to a tag (not yet)
|
|
|
|
* - message to followers related to a tag (not yet)
|
|
|
|
*
|
2019-01-07 10:09:53 +00:00
|
|
|
* @param Person $actor
|
2019-01-04 19:42:58 +00:00
|
|
|
* @param string $hashtag
|
|
|
|
* @param int $since
|
|
|
|
* @param int $limit
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2019-01-07 10:09:53 +00:00
|
|
|
public function getStreamTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5
|
|
|
|
): array {
|
2019-01-04 19:42:58 +00:00
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
|
2019-01-07 10:09:53 +00:00
|
|
|
$on = $this->exprJoinFollowing($qb, $actor);
|
|
|
|
$on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false));
|
|
|
|
$on->add($this->exprLimitToRecipient($qb, $actor->getId(), true));
|
|
|
|
$qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'f', $on);
|
2019-01-04 19:42:58 +00:00
|
|
|
|
2019-01-11 08:33:01 +00:00
|
|
|
$qb->andWhere($this->exprValueWithinJsonFormat($qb, 'hashtags', '' . $hashtag));
|
2019-01-04 19:42:58 +00:00
|
|
|
|
2019-01-07 10:09:53 +00:00
|
|
|
$this->limitPaginate($qb, $since, $limit);
|
2019-01-04 19:42:58 +00:00
|
|
|
$this->leftJoinCacheActors($qb, 'attributed_to');
|
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-06 12:50:45 +00:00
|
|
|
/**
|
|
|
|
* @param int $since
|
|
|
|
*
|
|
|
|
* @return Note[]
|
|
|
|
*/
|
|
|
|
public function getNotesSince(int $since): array {
|
|
|
|
$qb = $this->getNotesSelectSql();
|
|
|
|
$this->limitToSince($qb, $since, 'published_time');
|
|
|
|
|
|
|
|
$notes = [];
|
|
|
|
$cursor = $qb->execute();
|
|
|
|
while ($data = $cursor->fetch()) {
|
|
|
|
$notes[] = $this->parseNotesSelectSql($data);
|
|
|
|
}
|
|
|
|
$cursor->closeCursor();
|
|
|
|
|
|
|
|
return $notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-20 12:47:14 +00:00
|
|
|
/**
|
|
|
|
* @param string $id
|
|
|
|
*/
|
|
|
|
public function deleteNoteById(string $id) {
|
|
|
|
$qb = $this->getNotesDeleteSql();
|
|
|
|
$this->limitToIdString($qb, $id);
|
|
|
|
|
|
|
|
$qb->execute();
|
|
|
|
}
|
|
|
|
|
2019-02-11 11:01:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $actorId
|
|
|
|
*/
|
|
|
|
public function deleteByAuthor(string $actorId) {
|
|
|
|
$qb = $this->getNotesDeleteSql();
|
|
|
|
$this->limitToAttributedTo($qb, $actorId);
|
|
|
|
|
|
|
|
$qb->execute();
|
|
|
|
}
|
|
|
|
|
2019-02-23 00:04:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a new Note in the database.
|
|
|
|
*
|
|
|
|
* @param Stream $note
|
|
|
|
*
|
|
|
|
* @return IQueryBuilder
|
|
|
|
*/
|
|
|
|
public function saveStream(Stream $note): IQueryBuilder {
|
|
|
|
$dTime = new DateTime();
|
|
|
|
$dTime->setTimestamp($note->getPublishedTime());
|
|
|
|
|
|
|
|
$cache = '[]';
|
|
|
|
if ($note->gotCache()) {
|
|
|
|
$cache = json_encode($note->getCache(), JSON_UNESCAPED_SLASHES);
|
|
|
|
}
|
|
|
|
|
|
|
|
$qb = $this->getNotesInsertSql();
|
|
|
|
$qb->setValue('id', $qb->createNamedParameter($note->getId()))
|
|
|
|
->setValue('type', $qb->createNamedParameter($note->getType()))
|
|
|
|
->setValue('to', $qb->createNamedParameter($note->getTo()))
|
|
|
|
->setValue(
|
|
|
|
'to_array', $qb->createNamedParameter(
|
|
|
|
json_encode($note->getToArray(), JSON_UNESCAPED_SLASHES)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
->setValue(
|
|
|
|
'cc', $qb->createNamedParameter(
|
|
|
|
json_encode($note->getCcArray(), JSON_UNESCAPED_SLASHES)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
->setValue(
|
|
|
|
'bcc', $qb->createNamedParameter(
|
|
|
|
json_encode($note->getBccArray()), JSON_UNESCAPED_SLASHES
|
|
|
|
)
|
|
|
|
)
|
|
|
|
->setValue('content', $qb->createNamedParameter($note->getContent()))
|
|
|
|
->setValue('summary', $qb->createNamedParameter($note->getSummary()))
|
|
|
|
->setValue('published', $qb->createNamedParameter($note->getPublished()))
|
|
|
|
->setValue(
|
|
|
|
'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)
|
|
|
|
)
|
|
|
|
->setValue('attributed_to', $qb->createNamedParameter($note->getAttributedTo()))
|
|
|
|
->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo()))
|
|
|
|
->setValue('source', $qb->createNamedParameter($note->getSource()))
|
|
|
|
->setValue('object_id', $qb->createNamedParameter($note->getObjectId()))
|
|
|
|
->setValue('cache', $qb->createNamedParameter($cache))
|
|
|
|
->setValue(
|
|
|
|
'instances', $qb->createNamedParameter(
|
|
|
|
json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
->setValue('local', $qb->createNamedParameter(($note->isLocal()) ? '1' : '0'))
|
|
|
|
->setValue(
|
|
|
|
'creation',
|
|
|
|
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $qb;
|
|
|
|
}
|
|
|
|
|
2018-09-28 11:41:24 +00:00
|
|
|
}
|
2018-11-20 12:47:14 +00:00
|
|
|
|