summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appinfo/database.xml6
-rw-r--r--appinfo/info.xml2
-rw-r--r--composer.lock8
-rw-r--r--lib/Controller/AccountController.php2
-rw-r--r--lib/Controller/ActivityPubController.php2
-rw-r--r--lib/Controller/LocalController.php2
-rw-r--r--lib/Controller/NavigationController.php2
-rw-r--r--lib/Controller/SocialPubController.php2
-rw-r--r--lib/Db/NotesRequest.php11
-rw-r--r--lib/Db/NotesRequestBuilder.php4
-rw-r--r--lib/Model/ActivityPub/Note.php46
11 files changed, 69 insertions, 18 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml
index 1ae367ac..f7b137cc 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -196,6 +196,12 @@
</field>
<field>
+ <name>published_time</name>
+ <type>timestamp</type>
+ <default>0</default>
+ </field>
+
+ <field>
<name>attributed_to</name>
<type>text</type>
<length>127</length>
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 25da3d69..3ff28c34 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,7 +5,7 @@
<name>Social</name>
<summary>🎉 Nextcloud becomes part of the federated social networks!</summary>
<description><![CDATA[test]]></description>
- <version>0.0.32</version>
+ <version>0.0.33</version>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com">Maxence Lange</author>
<author mail="jus@bitgrid.net">Julius Härtl</author>
diff --git a/composer.lock b/composer.lock
index 859a4f72..213b44de 100644
--- a/composer.lock
+++ b/composer.lock
@@ -12,12 +12,12 @@
"source": {
"type": "git",
"url": "https://github.com/daita/my-small-php-tools.git",
- "reference": "f063c1101ee10e9cee68cc0cedbccd3aedec5ad3"
+ "reference": "d3e752060bde0206e6153b84ec1a7c8ff973fb75"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/f063c1101ee10e9cee68cc0cedbccd3aedec5ad3",
- "reference": "f063c1101ee10e9cee68cc0cedbccd3aedec5ad3",
+ "url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/d3e752060bde0206e6153b84ec1a7c8ff973fb75",
+ "reference": "d3e752060bde0206e6153b84ec1a7c8ff973fb75",
"shasum": ""
},
"require": {
@@ -40,7 +40,7 @@
}
],
"description": "My small PHP Tools",
- "time": "2018-11-12T11:01:02+00:00"
+ "time": "2018-11-16T10:15:50+00:00"
}
],
"packages-dev": [],
diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php
index 3c15c6a6..ae56a850 100644
--- a/lib/Controller/AccountController.php
+++ b/lib/Controller/AccountController.php
@@ -31,7 +31,7 @@ declare(strict_types=1);
namespace OCA\Social\Controller;
-use daita\MySmallPhpTools\Traits\TNCDataResponse;
+use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use Exception;
use OCA\Social\AppInfo\Application;
use OCA\Social\Service\ActorService;
diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php
index 75dc25cb..f31df274 100644
--- a/lib/Controller/ActivityPubController.php
+++ b/lib/Controller/ActivityPubController.php
@@ -30,7 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Controller;
-use daita\MySmallPhpTools\Traits\TNCDataResponse;
+use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use Exception;
use OCA\Social\AppInfo\Application;
use OCA\Social\Db\NotesRequest;
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index 2510c028..0bb7b1bb 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -31,7 +31,7 @@ namespace OCA\Social\Controller;
use daita\MySmallPhpTools\Traits\TArrayTools;
-use daita\MySmallPhpTools\Traits\TNCDataResponse;
+use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use Exception;
use OCA\Social\AppInfo\Application;
use OCA\Social\Model\Post;
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php
index b1cc0782..e19e9ff2 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -31,7 +31,7 @@ namespace OCA\Social\Controller;
use daita\MySmallPhpTools\Traits\TArrayTools;
-use daita\MySmallPhpTools\Traits\TNCDataResponse;
+use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use OC\User\NoUserException;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\AccountAlreadyExistsException;
diff --git a/lib/Controller/SocialPubController.php b/lib/Controller/SocialPubController.php
index f4fafb4d..4783c90e 100644
--- a/lib/Controller/SocialPubController.php
+++ b/lib/Controller/SocialPubController.php
@@ -30,7 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Controller;
-use daita\MySmallPhpTools\Traits\TNCDataResponse;
+use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use OCA\Social\AppInfo\Application;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\ActorService;
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']);
diff --git a/lib/Model/ActivityPub/Note.php b/lib/Model/ActivityPub/Note.php
index 92aa0a16..df2f77e9 100644
--- a/lib/Model/ActivityPub/Note.php
+++ b/lib/Model/ActivityPub/Note.php
@@ -30,7 +30,9 @@ declare(strict_types=1);
namespace OCA\Social\Model\ActivityPub;
+use DateTime;
use JsonSerializable;
+use OCA\Social\Service\ActivityService;
class Note extends ACore implements JsonSerializable {
@@ -50,6 +52,9 @@ class Note extends ACore implements JsonSerializable {
/** @var string */
private $conversation = '';
+ /** @var int */
+ private $publishedTime;
+
/**
* Note constructor.
@@ -158,6 +163,34 @@ class Note extends ACore implements JsonSerializable {
/**
+ * @return int
+ */
+ public function getPublishedTime(): int {
+ return $this->publishedTime;
+ }
+
+ /**
+ * @param int $time
+ *
+ * @return Note
+ */
+ public function setPublishedTime(int $time): Note {
+ $this->publishedTime = $time;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function convertPublished() {
+ $dTime = new DateTime($this->getPublished());
+ $dTime->format(ActivityService::DATE_FORMAT);
+ $this->publishedTime = $dTime->getTimestamp();
+ }
+
+
+ /**
* @param array $data
*/
public function import(array $data) {
@@ -169,6 +202,7 @@ class Note extends ACore implements JsonSerializable {
$this->setSensitive($this->getBool('sensitive', $data, false));
$this->setConversation($this->get('conversation', $data, ''));
$this->setContent($this->get('content', $data, ''));
+ $this->convertPublished();
}
@@ -179,12 +213,12 @@ class Note extends ACore implements JsonSerializable {
return array_merge(
parent::jsonSerialize(),
[
- 'content' => $this->getContent(),
- 'published' => $this->getPublished(),
- 'attributedTo' => $this->getRoot() . $this->getAttributedTo(),
- 'inReplyTo' => $this->getInReplyTo(),
- 'sensitive' => $this->isSensitive(),
- 'conversation' => $this->getConversation()
+ 'content' => $this->getContent(),
+ 'publishedTime' => $this->getPublishedTime(),
+ 'attributedTo' => $this->getRoot() . $this->getAttributedTo(),
+ 'inReplyTo' => $this->getInReplyTo(),
+ 'sensitive' => $this->isSensitive(),
+ 'conversation' => $this->getConversation()
]
);
}