summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-11-30 10:02:25 -0100
committerMaxence Lange <maxence@artificial-owl.com>2018-11-30 10:02:25 -0100
commit75447af7671b9e45d3f5db0ba75bbfcd6a0318a3 (patch)
tree918ca0f86c3629499ca363080668dc115644ecb5 /lib
parent8b9ca910ba3b0fa7e33c664689954413f0430700 (diff)
parent011074646a68e7d80ff1edccbe627f06d4b401f6 (diff)
Merge remote-tracking branch 'origin/more-for-local-accounts' into more-for-local-accounts
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/NavigationController.php7
-rw-r--r--lib/Db/CacheActorsRequest.php26
-rw-r--r--lib/Db/FollowsRequestBuilder.php16
3 files changed, 48 insertions, 1 deletions
diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php
index 82713dbd..b14f46bd 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -45,6 +45,7 @@ use OCA\Social\Service\ActorService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\RedirectResponse;
@@ -186,7 +187,11 @@ class NavigationController extends Controller {
// neither.
}
- return new TemplateResponse(Application::APP_NAME, 'main', $data);
+ $csp = new ContentSecurityPolicy();
+ $csp->addAllowedImageDomain('*');
+ $response = new TemplateResponse(Application::APP_NAME, 'main', $data);
+ $response->setContentSecurityPolicy($csp);
+ return $response;
}
diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php
index 85c4a2e8..1be44384 100644
--- a/lib/Db/CacheActorsRequest.php
+++ b/lib/Db/CacheActorsRequest.php
@@ -202,6 +202,32 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
/**
+ * get Cached version of a local Actor, based on the preferred username
+ *
+ * @param string $account
+ *
+ * @return Person
+ * @throws CacheActorDoesNotExistException
+ */
+ public function getFromLocalAccount(string $account): Person {
+ $qb = $this->getCacheActorsSelectSql();
+ $this->limitToPreferredUsername($qb, $account);
+ $this->limitToLocal($qb, true);
+ $this->leftJoinCacheDocuments($qb, 'icon_id');
+
+ $cursor = $qb->execute();
+ $data = $cursor->fetch();
+ $cursor->closeCursor();
+
+ if ($data === false) {
+ throw new CacheActorDoesNotExistException();
+ }
+
+ return $this->parseCacheActorsSelectSql($data);
+ }
+
+
+ /**
* @param string $search
* @param string $viewerId
*
diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php
index 0f50b37e..3a1d9445 100644
--- a/lib/Db/FollowsRequestBuilder.php
+++ b/lib/Db/FollowsRequestBuilder.php
@@ -109,6 +109,22 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
/**
+ * Base of the Sql Select request for Shares
+ *
+ * @return IQueryBuilder
+ */
+ protected function countFollowsSelectSql(): IQueryBuilder {
+ $qb = $this->dbConnection->getQueryBuilder();
+ $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
+ ->from(self::TABLE_SERVER_FOLLOWS, 'f');
+
+ $this->defaultSelectAlias = 'f';
+
+ return $qb;
+ }
+
+
+ /**
* Base of the Sql Delete request
*
* @return IQueryBuilder