summaryrefslogtreecommitdiffstats
path: root/lib/Db
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-11-16 09:47:59 -0100
committerMaxence Lange <maxence@artificial-owl.com>2018-11-16 09:47:59 -0100
commit26dad9973e7d151d8b6f2c126e1353dac8d870f8 (patch)
treeeb9fb9b11e502fefca772767720d168a9c6661c3 /lib/Db
parent595e734a81ed5c2c3612e8cfac0f5a2d0b08846f (diff)
converting published time
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db')
-rw-r--r--lib/Db/NotesRequest.php11
-rw-r--r--lib/Db/NotesRequestBuilder.php4
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php
index c7dbd893..83994763 100644
--- a/lib/Db/NotesRequest.php
+++ b/lib/Db/NotesRequest.php
@@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Db;
+use DateTime;
use OCA\Social\Model\ActivityPub\Note;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\ConfigService;
@@ -64,6 +65,10 @@ class NotesRequest extends NotesRequestBuilder {
*/
public function save(Note $note): int {
try {
+
+ $dTime = new DateTime();
+ $dTime->setTimestamp($note->getPublishedTime());
+
$qb = $this->getNotesInsertSql();
$qb->setValue('id', $qb->createNamedParameter($note->getId()))
->setValue('to', $qb->createNamedParameter($note->getTo()))
@@ -85,13 +90,17 @@ class NotesRequest extends NotesRequestBuilder {
->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(
'creation',
- $qb->createNamedParameter(new \DateTime('now'), IQueryBuilder::PARAM_DATE)
+ $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
);
+
$qb->execute();
return $qb->getLastInsertId();
diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/NotesRequestBuilder.php
index 3e50fd29..72fc808c 100644
--- a/lib/Db/NotesRequestBuilder.php
+++ b/lib/Db/NotesRequestBuilder.php
@@ -78,7 +78,8 @@ class NotesRequestBuilder extends CoreRequestBuilder {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->select(
'sn.id', 'sn.to', 'sn.to_array', 'sn.cc', 'sn.bcc', 'sn.content', 'sn.summary',
- 'sn.published', 'sn.attributed_to', 'sn.in_reply_to', 'sn.source', 'sn.creation'
+ 'sn.published', 'sn.published_time', 'sn.attributed_to', 'sn.in_reply_to', 'sn.source',
+ 'sn.creation'
)
->from(self::TABLE_SERVER_NOTES, 'sn');
@@ -115,6 +116,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
->setBccArray(json_decode($data['bcc']))
->setPublished($data['published']);
$note->setContent($data['content'])
+ ->setPublishedTime($this->getInt('published_time', $data, 0))
->setAttributedTo($data['attributed_to'])
->setInReplyTo($data['in_reply_to']);