From ed8330d3f2a90e67ac9ce5deb0999bd37f540073 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Sun, 28 Apr 2024 07:23:28 +0200 Subject: [PATCH 01/10] 1203: Started work on Notified feed --- src/Feed/NotifiedFeedType.php | 241 +++++++++++++++++++++++++++++++++ src/Feed/SparkleIOFeedType.php | 1 + 2 files changed, 242 insertions(+) create mode 100644 src/Feed/NotifiedFeedType.php diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php new file mode 100644 index 00000000..181655c6 --- /dev/null +++ b/src/Feed/NotifiedFeedType.php @@ -0,0 +1,241 @@ +getFeedSource()?->getSecrets(); + if (!isset($secrets['token'])) { + return []; + } + + $configuration = $feed->getConfiguration(); + if (!isset($configuration['feeds']) || 0 === count($configuration['feeds'])) { + return []; + } + + $token = $secrets['token']; + + $res = $this->client->request( + 'POST', + self::BASE_URL.'/api/listen/mentions', + [ + 'timeout' => self::REQUEST_TIMEOUT, + 'headers' => [ + "Accept" => 'application/json', + "Content-Type" => 'application/json', + 'Notified-Custom-Token' => $token, + ], + 'body' => json_encode([ + "pageSize" => 10, + "page" => 1, + "mediaTypes" => [], + "searchProfileIds" => $configuration['feeds'], + "tagIds" => [], + "from" => "2023-06-24T11:23:30.294Z", + "to" => "2024-04-30T11:23:30.294Z", + "sourceIds" => [], + ]) + ] + ); + + $contents = $res->getContent(); + $data = json_decode($contents, false, 512, JSON_THROW_ON_ERROR); + + $res = []; + foreach ($data as $item) { + $res[] = $this->getFeedItemObject($item); + } + + return $res; + } catch (\Throwable $throwable) { + $this->logger->error('{code}: {message}', [ + 'code' => $throwable->getCode(), + 'message' => $throwable->getMessage(), + ]); + } + + return []; + } + + /** + * {@inheritDoc} + */ + public function getAdminFormOptions(FeedSource $feedSource): array + { + $endpoint = $this->feedService->getFeedSourceConfigUrl($feedSource, 'feeds'); + + // @TODO: Translation. + return [ + [ + 'key' => 'notified-selector', + 'input' => 'multiselect-from-endpoint', + 'endpoint' => $endpoint, + 'name' => 'feeds', + 'label' => 'Vælg feed', + 'helpText' => 'Her vælger du hvilket feed der skal hentes indgange fra.', + 'formGroupClasses' => 'col-md-6 mb-3', + ], + ]; + } + + /** + * {@inheritDoc} + */ + public function getConfigOptions(Request $request, FeedSource $feedSource, string $name): ?array + { + try { + if ('feeds' === $name) { + $secrets = $feedSource->getSecrets(); + + if (!isset($secrets['token'])) { + return []; + } + + $token = $secrets['token']; + + $response = $this->client->request( + 'GET', + self::BASE_URL.'/api/listen/searchprofiles', + [ + 'timeout' => self::REQUEST_TIMEOUT, + 'headers' => [ + "Accept" => 'application/json', + "Content-Type" => 'application/json', + 'Notified-Custom-Token' => $token, + ], + ] + ); + + $contents = $response->getContent(); + + $items = json_decode($contents, null, 512, JSON_THROW_ON_ERROR); + + $feeds = []; + + foreach ($items as $item) { + $feeds[] = [ + 'id' => Ulid::generate(), + 'title' => $item->name ?? '', + 'value' => $item->id ?? '', + ]; + } + + return $feeds; + } + } catch (\Throwable $throwable) { + $this->logger->error('{code}: {message}', [ + 'code' => $throwable->getCode(), + 'message' => $throwable->getMessage(), + ]); + } + + return null; + } + + /** + * {@inheritDoc} + */ + public function getRequiredSecrets(): array + { + return ['token']; + } + + /** + * {@inheritDoc} + */ + public function getRequiredConfiguration(): array + { + return ['feeds']; + } + + /** + * {@inheritDoc} + */ + public function getSupportedFeedOutputType(): string + { + return self::SUPPORTED_FEED_TYPE; + } + + /** + * Parse feed item into object. + * + * @return object + */ + private function getFeedItemObject(object $item): object + { + return (object) [ + 'text' => $item->description ?? null, + 'textMarkup' => null !== $item->description ? $this->wrapTags($item->description) : null, + 'mediaUrl' => $item->mediaUrl ?? null, + 'videoUrl' => $item->videoUrl ?? null, + 'username' => $item->sourceName ?? null, + 'createdTime' => $item->published ?? null, + ]; + } + + /** + * @return string + */ + private function wrapTags(string $input): string + { + $text = trim($input); + + // Strip unicode zero-width-space. + $text = str_replace("\xE2\x80\x8B", '', $text); + + // Collects trailing tags one by one. + $trailingTags = []; + $pattern = "/\s*#(?[^\s#]+)\n?$/u"; + while (preg_match($pattern, (string) $text, $matches)) { + // We're getting tags in reverse order. + array_unshift($trailingTags, $matches['tag']); + $text = preg_replace($pattern, '', (string) $text); + } + + // Wrap sections in p tags. + $text = preg_replace("/(.+)\n?/u", '

\1

', (string) $text); + + // Wrap inline tags. + $pattern = '/(#(?[^\s#]+))/'; + $text = '
'.preg_replace($pattern, + '\1', (string) $text).'
'; + // Append tags. + $text .= PHP_EOL.'
'.implode(' ', + array_map(fn ($tag) => '#'.$tag.'', $trailingTags)).'
'; + + return $text; + } +} diff --git a/src/Feed/SparkleIOFeedType.php b/src/Feed/SparkleIOFeedType.php index fc40c4ed..ab52be27 100644 --- a/src/Feed/SparkleIOFeedType.php +++ b/src/Feed/SparkleIOFeedType.php @@ -19,6 +19,7 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; +/** @deprecated The SparkleIO service is discontinued. */ class SparkleIOFeedType implements FeedTypeInterface { final public const SUPPORTED_FEED_TYPE = 'instagram'; From 725f64160746decc0aed25f7d1653bd081135937 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:27:33 +0200 Subject: [PATCH 02/10] 1203: Added interest period to latest month --- src/Feed/NotifiedFeedType.php | 63 ++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php index 181655c6..c329e583 100644 --- a/src/Feed/NotifiedFeedType.php +++ b/src/Feed/NotifiedFeedType.php @@ -7,6 +7,7 @@ use App\Entity\Tenant\Feed; use App\Entity\Tenant\FeedSource; use App\Service\FeedService; +use DateInterval; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Uid\Ulid; @@ -28,11 +29,6 @@ public function __construct( private readonly LoggerInterface $logger ) {} - /** - * @param Feed $feed - * - * @return array - */ public function getData(Feed $feed): array { try { @@ -46,8 +42,28 @@ public function getData(Feed $feed): array return []; } + $slide = $feed->getSlide(); + $slideContent = $slide->getContent(); + + $pageSize = $slideContent['maxEntries'] ?? 10; + $token = $secrets['token']; + // Take content from the last month + $to = (new \DateTime())->setTimezone(new \DateTimeZone('UTC')); + $from = (clone $to)->sub(new DateInterval('P1M')); + + $body = [ + "pageSize" => $pageSize, + "page" => 1, + "mediaTypes" => [], + "searchProfileIds" => $configuration['feeds'], + "tagIds" => [], + "from" => $from->format('Y-m-d\TH:i:s.vp'), + "to" => $to->format('Y-m-d\TH:i:s.vp'), + "sourceIds" => [], + ]; + $res = $this->client->request( 'POST', self::BASE_URL.'/api/listen/mentions', @@ -58,16 +74,7 @@ public function getData(Feed $feed): array "Content-Type" => 'application/json', 'Notified-Custom-Token' => $token, ], - 'body' => json_encode([ - "pageSize" => 10, - "page" => 1, - "mediaTypes" => [], - "searchProfileIds" => $configuration['feeds'], - "tagIds" => [], - "from" => "2023-06-24T11:23:30.294Z", - "to" => "2024-04-30T11:23:30.294Z", - "sourceIds" => [], - ]) + 'body' => json_encode($body), ] ); @@ -191,8 +198,6 @@ public function getSupportedFeedOutputType(): string /** * Parse feed item into object. - * - * @return object */ private function getFeedItemObject(object $item): object { @@ -200,15 +205,13 @@ private function getFeedItemObject(object $item): object 'text' => $item->description ?? null, 'textMarkup' => null !== $item->description ? $this->wrapTags($item->description) : null, 'mediaUrl' => $item->mediaUrl ?? null, - 'videoUrl' => $item->videoUrl ?? null, + // Video is not supported by the Notified Listen API. + 'videoUrl' => null, 'username' => $item->sourceName ?? null, 'createdTime' => $item->published ?? null, ]; } - /** - * @return string - */ private function wrapTags(string $input): string { $text = trim($input); @@ -230,12 +233,18 @@ private function wrapTags(string $input): string // Wrap inline tags. $pattern = '/(#(?[^\s#]+))/'; - $text = '
'.preg_replace($pattern, - '\1', (string) $text).'
'; - // Append tags. - $text .= PHP_EOL.'
'.implode(' ', - array_map(fn ($tag) => '#'.$tag.'', $trailingTags)).'
'; - return $text; + return implode('', [ + '
', + preg_replace($pattern, '\1', (string) $text), + '
', + // Append tags. + PHP_EOL, + '
', + implode(' ', + array_map(fn ($tag) => '#'.$tag.'', $trailingTags) + ), + '
' + ]); } } From 33a4dc4291e0c0731087c3219ccaacc10c30ca14 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Tue, 30 Apr 2024 06:38:26 +0200 Subject: [PATCH 03/10] 1203: Simplified code --- src/Feed/NotifiedFeedType.php | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php index c329e583..3237a19b 100644 --- a/src/Feed/NotifiedFeedType.php +++ b/src/Feed/NotifiedFeedType.php @@ -7,7 +7,6 @@ use App\Entity\Tenant\Feed; use App\Entity\Tenant\FeedSource; use App\Service\FeedService; -use DateInterval; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Uid\Ulid; @@ -49,19 +48,10 @@ public function getData(Feed $feed): array $token = $secrets['token']; - // Take content from the last month - $to = (new \DateTime())->setTimezone(new \DateTimeZone('UTC')); - $from = (clone $to)->sub(new DateInterval('P1M')); - $body = [ "pageSize" => $pageSize, "page" => 1, - "mediaTypes" => [], "searchProfileIds" => $configuration['feeds'], - "tagIds" => [], - "from" => $from->format('Y-m-d\TH:i:s.vp'), - "to" => $to->format('Y-m-d\TH:i:s.vp'), - "sourceIds" => [], ]; $res = $this->client->request( @@ -81,12 +71,7 @@ public function getData(Feed $feed): array $contents = $res->getContent(); $data = json_decode($contents, false, 512, JSON_THROW_ON_ERROR); - $res = []; - foreach ($data as $item) { - $res[] = $this->getFeedItemObject($item); - } - - return $res; + return array_map(fn (object $item) => $this->getFeedItemObject($item), $data); } catch (\Throwable $throwable) { $this->logger->error('{code}: {message}', [ 'code' => $throwable->getCode(), @@ -150,17 +135,11 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin $items = json_decode($contents, null, 512, JSON_THROW_ON_ERROR); - $feeds = []; - - foreach ($items as $item) { - $feeds[] = [ - 'id' => Ulid::generate(), - 'title' => $item->name ?? '', - 'value' => $item->id ?? '', - ]; - } - - return $feeds; + return array_map(fn (object $item) => [ + 'id' => Ulid::generate(), + 'title' => $item->name ?? '', + 'value' => $item->id ?? '', + ], $items); } } catch (\Throwable $throwable) { $this->logger->error('{code}: {message}', [ From 44cd808b39f95094a0e46c37da61c3b655c45ea6 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:10:35 +0200 Subject: [PATCH 04/10] 1203: Added tests --- composer.json | 4 + fixtures/feed.yaml | 23 ++++-- fixtures/feed_source.yaml | 35 +++++---- fixtures/slide.yaml | 60 ++++++++------- fixtures/template.yaml | 21 +++-- src/Feed/NotifiedFeedType.php | 114 +++++++++++++++------------- tests/Api/FeedSourceTest.php | 4 +- tests/Api/SlidesTest.php | 2 +- tests/Feed/NotifiedFeedTypeData.php | 86 +++++++++++++++++++++ tests/Feed/NotifiedFeedTypeTest.php | 64 ++++++++++++++++ 10 files changed, 301 insertions(+), 112 deletions(-) create mode 100644 tests/Feed/NotifiedFeedTypeData.php create mode 100644 tests/Feed/NotifiedFeedTypeTest.php diff --git a/composer.json b/composer.json index 675c86b3..f9bccae3 100644 --- a/composer.json +++ b/composer.json @@ -143,6 +143,10 @@ "bin/console --env=test doctrine:database:create --no-interaction --if-not-exists --quiet", "bin/console --env=test doctrine:migrations:migrate --no-interaction --quiet" ], + "run-tests": [ + "@test-setup", + "@test tests/Feed/NotifiedFeedTypeTest.php" + ], "update-api-spec": [ "bin/console api:openapi:export --output=public/api-spec-v2.yaml --yaml --no-interaction", "bin/console api:openapi:export --output=public/api-spec-v2.json --no-interaction" diff --git a/fixtures/feed.yaml b/fixtures/feed.yaml index e8d2f68a..117d2807 100644 --- a/fixtures/feed.yaml +++ b/fixtures/feed.yaml @@ -1,9 +1,18 @@ --- App\Entity\Tenant\Feed: - feed_abc_1: - feedSource: '@feed_source_abc_1' - slide: '@slide_abc_1' - tenant: '@tenant_abc' - createdAt (unique): '' - modifiedAt: '' - id: '' + feed_abc_1: + feedSource: '@feed_source_abc_1' + slide: '@slide_abc_1' + tenant: '@tenant_abc' + createdAt (unique): '' + modifiedAt: '' + id: '' + feed_abc_notified: + feedSource: '@feed_source_abc_notified' + slide: '@slide_abc_notified' + tenant: '@tenant_abc' + createdAt (unique): '' + modifiedAt: '' + id: '' + configuration: + feeds: [12345] diff --git a/fixtures/feed_source.yaml b/fixtures/feed_source.yaml index 67e125ac..3a2c3c81 100644 --- a/fixtures/feed_source.yaml +++ b/fixtures/feed_source.yaml @@ -1,16 +1,23 @@ --- App\Entity\Tenant\FeedSource: - feed (template): - description: - feedType: "App\\Feed\\RssFeedType" - secrets: [] - supportedFeedOutputType: 'rss' - createdAt (unique): '' - modifiedAt: '' - id: '' - feed_source_abc_1 (extends feed): - title: 'feed_source_abc_1' - tenant: '@tenant_abc' - feed_source_xyz_2 (extends feed): - title: 'feed_source_xyz_2' - tenant: '@tenant_xyz' + feed (template): + description: + feedType: "App\\Feed\\RssFeedType" + secrets: [ ] + supportedFeedOutputType: 'rss' + createdAt (unique): '' + modifiedAt: '' + id: '' + feed_source_abc_1 (extends feed): + title: 'feed_source_abc_1' + tenant: '@tenant_abc' + feed_source_xyz_2 (extends feed): + title: 'feed_source_xyz_2' + tenant: '@tenant_xyz' + feed_source_abc_notified (extends feed): + title: 'feed_source_abc_notified' + feedType: "App\\Feed\\RssFeedType" + secrets: + token: '1234567890' + supportedFeedOutputType: 'instagram' + tenant: '@tenant_abc' diff --git a/fixtures/slide.yaml b/fixtures/slide.yaml index cec3800d..288b7dbc 100644 --- a/fixtures/slide.yaml +++ b/fixtures/slide.yaml @@ -1,30 +1,36 @@ --- App\Entity\Tenant\Slide: - slide (template): - description: - duration: - template: '@template_image_text' - createdAt (unique): '' - modifiedAt: '' - id: '' + slide (template): + description: + duration: + template: '@template_image_text' + createdAt (unique): '' + modifiedAt: '' + id: '' - slide_abc_1 (extends slide): - title: 'slide_abc_1' - theme: '@theme_abc_1' - feed: '@feed_abc_1' - tenant: '@tenant_abc' - media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*'] - slide_abc_{2..60} (extends slide): - title: 'slide_abc_' - theme: '@theme_abc_*' - tenant: '@tenant_abc' - media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*'] - slide_def_shared_to_abc (extends slide): - title: 'slide_def_shared_to_abc' - theme: '@theme_def' - tenant: '@tenant_def' - media: [ '@media_def_shared_to_abc' ] - slide_xyz_{1..60} (extends slide): - title: 'slide_xyz_' - theme: '@theme_xyz' - tenant: '@tenant_xyz' + slide_abc_1 (extends slide): + title: 'slide_abc_1' + theme: '@theme_abc_1' + feed: '@feed_abc_1' + tenant: '@tenant_abc' + media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] + slide_abc_{2..60} (extends slide): + title: 'slide_abc_' + theme: '@theme_abc_*' + tenant: '@tenant_abc' + media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] + slide_def_shared_to_abc (extends slide): + title: 'slide_def_shared_to_abc' + theme: '@theme_def' + tenant: '@tenant_def' + media: [ '@media_def_shared_to_abc' ] + slide_xyz_{1..60} (extends slide): + title: 'slide_xyz_' + theme: '@theme_xyz' + tenant: '@tenant_xyz' + slide_abc_notified (extends slide): + title: 'slide_abc_notified' + template: '@template_notified' + content: + maxEntries: 6 + tenant: '@tenant_abc' diff --git a/fixtures/template.yaml b/fixtures/template.yaml index d477fa0b..843845f0 100644 --- a/fixtures/template.yaml +++ b/fixtures/template.yaml @@ -1,9 +1,16 @@ --- App\Entity\Template: - template_image_text: - title: 'template_image_text' - description: A template with different formats of image and text - resources: - createdAt (unique): '' - modifiedAt: '' - id: '' + template_image_text: + title: 'template_image_text' + description: A template with different formats of image and text + resources: + createdAt (unique): '' + modifiedAt: '' + id: '' + template_notified: + title: 'template_notified' + description: A template with different that serves notified data + resources: + createdAt (unique): '' + modifiedAt: '' + id: '' diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php index 3237a19b..35367812 100644 --- a/src/Feed/NotifiedFeedType.php +++ b/src/Feed/NotifiedFeedType.php @@ -42,36 +42,15 @@ public function getData(Feed $feed): array } $slide = $feed->getSlide(); - $slideContent = $slide->getContent(); + $slideContent = $slide?->getContent(); $pageSize = $slideContent['maxEntries'] ?? 10; $token = $secrets['token']; - $body = [ - "pageSize" => $pageSize, - "page" => 1, - "searchProfileIds" => $configuration['feeds'], - ]; - - $res = $this->client->request( - 'POST', - self::BASE_URL.'/api/listen/mentions', - [ - 'timeout' => self::REQUEST_TIMEOUT, - 'headers' => [ - "Accept" => 'application/json', - "Content-Type" => 'application/json', - 'Notified-Custom-Token' => $token, - ], - 'body' => json_encode($body), - ] - ); - - $contents = $res->getContent(); - $data = json_decode($contents, false, 512, JSON_THROW_ON_ERROR); - - return array_map(fn (object $item) => $this->getFeedItemObject($item), $data); + $data = $this->getMentions($token, $pageSize, $configuration['feeds']); + + return array_map(fn (array $item) => $this->getFeedItemObject($item), $data); } catch (\Throwable $throwable) { $this->logger->error('{code}: {message}', [ 'code' => $throwable->getCode(), @@ -118,28 +97,13 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin $token = $secrets['token']; - $response = $this->client->request( - 'GET', - self::BASE_URL.'/api/listen/searchprofiles', - [ - 'timeout' => self::REQUEST_TIMEOUT, - 'headers' => [ - "Accept" => 'application/json', - "Content-Type" => 'application/json', - 'Notified-Custom-Token' => $token, - ], - ] - ); - - $contents = $response->getContent(); + $data = $this->getSearchProfiles($token); - $items = json_decode($contents, null, 512, JSON_THROW_ON_ERROR); - - return array_map(fn (object $item) => [ + return array_map(fn (array $item) => [ 'id' => Ulid::generate(), - 'title' => $item->name ?? '', - 'value' => $item->id ?? '', - ], $items); + 'title' => $item['name'] ?? '', + 'value' => $item['id'] ?? '', + ], $data); } } catch (\Throwable $throwable) { $this->logger->error('{code}: {message}', [ @@ -151,6 +115,49 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin return null; } + public function getMentions(string $token, int $pageSize = 10, array $searchProfileIds = []): array + { + $body = [ + "pageSize" => $pageSize, + "page" => 1, + "searchProfileIds" => $searchProfileIds, + ]; + + $res = $this->client->request( + 'POST', + self::BASE_URL.'/api/listen/mentions', + [ + 'timeout' => self::REQUEST_TIMEOUT, + 'headers' => [ + "Accept" => 'application/json', + "Content-Type" => 'application/json', + 'Notified-Custom-Token' => $token, + ], + 'body' => json_encode($body), + ] + ); + + return $res->toArray(); + } + + public function getSearchProfiles(string $token): array + { + $response = $this->client->request( + 'GET', + self::BASE_URL.'/api/listen/searchprofiles', + [ + 'timeout' => self::REQUEST_TIMEOUT, + 'headers' => [ + "Accept" => 'application/json', + "Content-Type" => 'application/json', + 'Notified-Custom-Token' => $token, + ], + ] + ); + + return $response->toArray(); + } + /** * {@inheritDoc} */ @@ -178,16 +185,17 @@ public function getSupportedFeedOutputType(): string /** * Parse feed item into object. */ - private function getFeedItemObject(object $item): object + private function getFeedItemObject(array $item): array { - return (object) [ - 'text' => $item->description ?? null, - 'textMarkup' => null !== $item->description ? $this->wrapTags($item->description) : null, - 'mediaUrl' => $item->mediaUrl ?? null, + $description = $item['description'] ?? null; + return [ + 'text' => $description, + 'textMarkup' => null !== $description ? $this->wrapTags($description) : null, + 'mediaUrl' => $item['mediaUrl'] ?? null, // Video is not supported by the Notified Listen API. 'videoUrl' => null, - 'username' => $item->sourceName ?? null, - 'createdTime' => $item->published ?? null, + 'username' => $item['sourceName'] ?? null, + 'createdTime' => $item['published'] ?? null, ]; } @@ -217,8 +225,6 @@ private function wrapTags(string $input): string '
', preg_replace($pattern, '\1', (string) $text), '
', - // Append tags. - PHP_EOL, '
', implode(' ', array_map(fn ($tag) => '#'.$tag.'', $trailingTags) diff --git a/tests/Api/FeedSourceTest.php b/tests/Api/FeedSourceTest.php index 50457efc..f0e1a000 100644 --- a/tests/Api/FeedSourceTest.php +++ b/tests/Api/FeedSourceTest.php @@ -20,14 +20,14 @@ public function testGetCollection(): void '@context' => '/contexts/FeedSource', '@id' => '/v2/feed-sources', '@type' => 'hydra:Collection', - 'hydra:totalItems' => 1, + 'hydra:totalItems' => 2, 'hydra:view' => [ '@id' => '/v2/feed-sources?itemsPerPage=10', '@type' => 'hydra:PartialCollectionView', ], ]); - $this->assertCount(1, $response->toArray()['hydra:member']); + $this->assertCount(2, $response->toArray()['hydra:member']); } public function testGetItem(): void diff --git a/tests/Api/SlidesTest.php b/tests/Api/SlidesTest.php index d1996a8f..84762aa6 100644 --- a/tests/Api/SlidesTest.php +++ b/tests/Api/SlidesTest.php @@ -22,7 +22,7 @@ public function testGetCollection(): void '@context' => '/contexts/Slide', '@id' => '/v2/slides', '@type' => 'hydra:Collection', - 'hydra:totalItems' => 60, + 'hydra:totalItems' => 61, 'hydra:view' => [ '@id' => '/v2/slides?itemsPerPage=10&page=1', '@type' => 'hydra:PartialCollectionView', diff --git a/tests/Feed/NotifiedFeedTypeData.php b/tests/Feed/NotifiedFeedTypeData.php new file mode 100644 index 00000000..953d5853 --- /dev/null +++ b/tests/Feed/NotifiedFeedTypeData.php @@ -0,0 +1,86 @@ + 12345, + "name" => "Test1", + "accountId" => 12345, + "categoryId" => 12345, + "categoryName" => "Test2", + "queries" => [ + "(\"#tag\")" + ], + "selectedMediaTypes" => [ + "instagram" + ] + ], + [ + "id" => 12346, + "name" => "Test3", + "accountId" => 12346, + "categoryId" => 12346, + "categoryName" => "Test4", + "queries" => [ + "(\"#tag\")" + ], + "selectedMediaTypes" => [ + "instagram" + ] + ] + ]; + } + + static function getData(): array + { + return [ + [ + "externalId" => "1_1111111111111111111", + "title" => null, + "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. #tag", + "sourceName" => "test", + "sourceUrl" => "https://example.com", + "author" => null, + "mediaUrl" => "/media/thumbnail_other.png", + "url" => "https://example.com", + "searchProfileId" => 123456, + "queryString" => "(\"#tag\")", + "languageCode" => "da", + "mediaType" => "instagram", + "published" => "2024-04-23T08:00:34", + "sentiment" => "positive", + "commonMetadata" => [ + "reach" => 0, + "engagement" => 9, + "authorImageUrl" => null + ], + "articleMetadata" => null, + "blogMetadata" => null, + "facebookMetadata" => null, + "forumMetadata" => null, + "instagramMetadata" => [ + "likeCount" => 9, + "commentCount" => 0, + "geo" => "0|0" + ], + "twitterMetadata" => null, + "youtubeMetadata" => null, + "rssMetadata" => null, + "printMetadata" => null, + "tikTokMetadata" => null, + "linkedInMetadata" => null, + "commonLocationData" => [ + "country" => "Denmark", + "countryCode" => "DK", + "latitude" => 55.67576, + "longitude" => 12.56902 + ] + ], + ]; + } +} diff --git a/tests/Feed/NotifiedFeedTypeTest.php b/tests/Feed/NotifiedFeedTypeTest.php new file mode 100644 index 00000000..00f897a0 --- /dev/null +++ b/tests/Feed/NotifiedFeedTypeTest.php @@ -0,0 +1,64 @@ +get(FeedSourceRepository::class); + + $feedSource = $feedSourceRepository->findOneBy(['title' => 'feed_source_abc_notified']); + + $feedService = $container->get(FeedService::class); + $logger = $container->get(LoggerInterface::class); + + $httpClientMock = $this->createMock(HttpClientInterface::class); + + $response = $this->createMock(ResponseInterface::class); + $response->method('toArray')->willReturn(NotifiedFeedTypeData::getConfigData()); + + $httpClientMock->method('request')->willReturn($response); + + $notifiedFeedType = new NotifiedFeedType($feedService, $httpClientMock, $logger); + + $feeds = $notifiedFeedType->getConfigOptions(new Request(), $feedSource, 'feeds'); + + $this->assertEquals(12345, $feeds[0]['value']); + $this->assertEquals('Test1', $feeds[0]['title']); + $this->assertEquals(12346, $feeds[1]['value']); + $this->assertEquals('Test3', $feeds[1]['title']); + + $httpClientMock = $this->createMock(HttpClientInterface::class); + + $response = $this->createMock(ResponseInterface::class); + $response->method('toArray')->willReturn( + NotifiedFeedTypeData::getData() + ); + + $httpClientMock->method('request')->willReturn($response); + + $notifiedFeedType = new NotifiedFeedType($feedService, $httpClientMock, $logger); + + $slideRepository = $container->get(SlideRepository::class); + + $slide = $slideRepository->findOneBy(['title' => 'slide_abc_notified']); + + $feed = $slide->getFeed(); + + $data = $notifiedFeedType->getData($feed); + + $this->assertCount(1, $data); + } +} From 678fc31190f800b95f16300cc5887cce821b6081 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:30:36 +0200 Subject: [PATCH 05/10] 1203: Fixed issues from automatic reviews --- CHANGELOG.md | 4 + src/Feed/NotifiedFeedType.php | 17 ++-- tests/Api/SlidesTest.php | 2 +- tests/Api/TemplatesTest.php | 4 +- tests/Feed/NotifiedFeedTypeData.php | 124 ++++++++++++++-------------- tests/Feed/NotifiedFeedTypeTest.php | 2 + 6 files changed, 81 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed4a741..d598fbe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- [#206](https://github.com/os2display/display-api-service/pull/206) + - Added support for Notified feed as replacement for SparkleIOFeedType. + - Deprecated SparkleIOFeedType. + ## [2.0.4] - 2024-04-25 - [#204](https://github.com/os2display/display-api-service/pull/204) diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php index 35367812..ebdc211d 100644 --- a/src/Feed/NotifiedFeedType.php +++ b/src/Feed/NotifiedFeedType.php @@ -118,9 +118,9 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin public function getMentions(string $token, int $pageSize = 10, array $searchProfileIds = []): array { $body = [ - "pageSize" => $pageSize, - "page" => 1, - "searchProfileIds" => $searchProfileIds, + 'pageSize' => $pageSize, + 'page' => 1, + 'searchProfileIds' => $searchProfileIds, ]; $res = $this->client->request( @@ -129,8 +129,8 @@ public function getMentions(string $token, int $pageSize = 10, array $searchProf [ 'timeout' => self::REQUEST_TIMEOUT, 'headers' => [ - "Accept" => 'application/json', - "Content-Type" => 'application/json', + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', 'Notified-Custom-Token' => $token, ], 'body' => json_encode($body), @@ -148,8 +148,8 @@ public function getSearchProfiles(string $token): array [ 'timeout' => self::REQUEST_TIMEOUT, 'headers' => [ - "Accept" => 'application/json', - "Content-Type" => 'application/json', + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', 'Notified-Custom-Token' => $token, ], ] @@ -188,6 +188,7 @@ public function getSupportedFeedOutputType(): string private function getFeedItemObject(array $item): array { $description = $item['description'] ?? null; + return [ 'text' => $description, 'textMarkup' => null !== $description ? $this->wrapTags($description) : null, @@ -229,7 +230,7 @@ private function wrapTags(string $input): string implode(' ', array_map(fn ($tag) => '#'.$tag.'', $trailingTags) ), - '
' + '', ]); } } diff --git a/tests/Api/SlidesTest.php b/tests/Api/SlidesTest.php index 84762aa6..9534461a 100644 --- a/tests/Api/SlidesTest.php +++ b/tests/Api/SlidesTest.php @@ -27,7 +27,7 @@ public function testGetCollection(): void '@id' => '/v2/slides?itemsPerPage=10&page=1', '@type' => 'hydra:PartialCollectionView', 'hydra:first' => '/v2/slides?itemsPerPage=10&page=1', - 'hydra:last' => '/v2/slides?itemsPerPage=10&page=6', + 'hydra:last' => '/v2/slides?itemsPerPage=10&page=7', ], ]); diff --git a/tests/Api/TemplatesTest.php b/tests/Api/TemplatesTest.php index 693fbcf1..a1318c06 100644 --- a/tests/Api/TemplatesTest.php +++ b/tests/Api/TemplatesTest.php @@ -19,14 +19,14 @@ public function testGetCollection(): void '@context' => '/contexts/Template', '@id' => '/v2/templates', '@type' => 'hydra:Collection', - 'hydra:totalItems' => 1, + 'hydra:totalItems' => 2, 'hydra:view' => [ '@id' => '/v2/templates?itemsPerPage=5', '@type' => 'hydra:PartialCollectionView', ], ]); - $this->assertCount(1, $response->toArray()['hydra:member']); + $this->assertCount(2, $response->toArray()['hydra:member']); // @TODO: resources: Object value found, but an array is required. In JSON it's an object but in the entity // it's an key array? So this test will fail. diff --git a/tests/Feed/NotifiedFeedTypeData.php b/tests/Feed/NotifiedFeedTypeData.php index 953d5853..a829c244 100644 --- a/tests/Feed/NotifiedFeedTypeData.php +++ b/tests/Feed/NotifiedFeedTypeData.php @@ -1,85 +1,87 @@ 12345, - "name" => "Test1", - "accountId" => 12345, - "categoryId" => 12345, - "categoryName" => "Test2", - "queries" => [ - "(\"#tag\")" + 'id' => 12345, + 'name' => 'Test1', + 'accountId' => 12345, + 'categoryId' => 12345, + 'categoryName' => 'Test2', + 'queries' => [ + '("#tag")', + ], + 'selectedMediaTypes' => [ + 'instagram', ], - "selectedMediaTypes" => [ - "instagram" - ] ], [ - "id" => 12346, - "name" => "Test3", - "accountId" => 12346, - "categoryId" => 12346, - "categoryName" => "Test4", - "queries" => [ - "(\"#tag\")" + 'id' => 12346, + 'name' => 'Test3', + 'accountId' => 12346, + 'categoryId' => 12346, + 'categoryName' => 'Test4', + 'queries' => [ + '("#tag")', + ], + 'selectedMediaTypes' => [ + 'instagram', ], - "selectedMediaTypes" => [ - "instagram" - ] - ] + ], ]; } - static function getData(): array + public static function getData(): array { return [ [ - "externalId" => "1_1111111111111111111", - "title" => null, - "description" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. #tag", - "sourceName" => "test", - "sourceUrl" => "https://example.com", - "author" => null, - "mediaUrl" => "/media/thumbnail_other.png", - "url" => "https://example.com", - "searchProfileId" => 123456, - "queryString" => "(\"#tag\")", - "languageCode" => "da", - "mediaType" => "instagram", - "published" => "2024-04-23T08:00:34", - "sentiment" => "positive", - "commonMetadata" => [ - "reach" => 0, - "engagement" => 9, - "authorImageUrl" => null + 'externalId' => '1_1111111111111111111', + 'title' => null, + 'description' => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. #tag", + 'sourceName' => 'test', + 'sourceUrl' => 'https://example.com', + 'author' => null, + 'mediaUrl' => '/media/thumbnail_other.png', + 'url' => 'https://example.com', + 'searchProfileId' => 123456, + 'queryString' => '("#tag")', + 'languageCode' => 'da', + 'mediaType' => 'instagram', + 'published' => '2024-04-23T08:00:34', + 'sentiment' => 'positive', + 'commonMetadata' => [ + 'reach' => 0, + 'engagement' => 9, + 'authorImageUrl' => null, + ], + 'articleMetadata' => null, + 'blogMetadata' => null, + 'facebookMetadata' => null, + 'forumMetadata' => null, + 'instagramMetadata' => [ + 'likeCount' => 9, + 'commentCount' => 0, + 'geo' => '0|0', ], - "articleMetadata" => null, - "blogMetadata" => null, - "facebookMetadata" => null, - "forumMetadata" => null, - "instagramMetadata" => [ - "likeCount" => 9, - "commentCount" => 0, - "geo" => "0|0" + 'twitterMetadata' => null, + 'youtubeMetadata' => null, + 'rssMetadata' => null, + 'printMetadata' => null, + 'tikTokMetadata' => null, + 'linkedInMetadata' => null, + 'commonLocationData' => [ + 'country' => 'Denmark', + 'countryCode' => 'DK', + 'latitude' => 55.67576, + 'longitude' => 12.56902, ], - "twitterMetadata" => null, - "youtubeMetadata" => null, - "rssMetadata" => null, - "printMetadata" => null, - "tikTokMetadata" => null, - "linkedInMetadata" => null, - "commonLocationData" => [ - "country" => "Denmark", - "countryCode" => "DK", - "latitude" => 55.67576, - "longitude" => 12.56902 - ] ], ]; } diff --git a/tests/Feed/NotifiedFeedTypeTest.php b/tests/Feed/NotifiedFeedTypeTest.php index 00f897a0..1469e225 100644 --- a/tests/Feed/NotifiedFeedTypeTest.php +++ b/tests/Feed/NotifiedFeedTypeTest.php @@ -1,5 +1,7 @@ Date: Tue, 30 Apr 2024 16:45:43 +0200 Subject: [PATCH 06/10] 1203: Fixed test case --- composer.json | 4 ---- tests/Utils/FeedServiceTest.php | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f9bccae3..675c86b3 100644 --- a/composer.json +++ b/composer.json @@ -143,10 +143,6 @@ "bin/console --env=test doctrine:database:create --no-interaction --if-not-exists --quiet", "bin/console --env=test doctrine:migrations:migrate --no-interaction --quiet" ], - "run-tests": [ - "@test-setup", - "@test tests/Feed/NotifiedFeedTypeTest.php" - ], "update-api-spec": [ "bin/console api:openapi:export --output=public/api-spec-v2.yaml --yaml --no-interaction", "bin/console api:openapi:export --output=public/api-spec-v2.json --no-interaction" diff --git a/tests/Utils/FeedServiceTest.php b/tests/Utils/FeedServiceTest.php index ad40aaea..d0637a72 100644 --- a/tests/Utils/FeedServiceTest.php +++ b/tests/Utils/FeedServiceTest.php @@ -9,6 +9,7 @@ use App\Feed\EventDatabaseApiFeedType; use App\Feed\FeedTypeInterface; use App\Feed\KobaFeedType; +use App\Feed\NotifiedFeedType; use App\Feed\RssFeedType; use App\Feed\SparkleIOFeedType; use App\Service\FeedService; @@ -36,8 +37,9 @@ public function testGetFeedTypes(): void $feedTypes = $this->feedService->getFeedTypes(); $this->assertEquals(EventDatabaseApiFeedType::class, $feedTypes[0]); $this->assertEquals(KobaFeedType::class, $feedTypes[1]); - $this->assertEquals(RssFeedType::class, $feedTypes[2]); - $this->assertEquals(SparkleIOFeedType::class, $feedTypes[3]); + $this->assertEquals(NotifiedFeedType::class, $feedTypes[2]); + $this->assertEquals(RssFeedType::class, $feedTypes[3]); + $this->assertEquals(SparkleIOFeedType::class, $feedTypes[4]); } public function testGetFeedUrl(): void From 59900a0e5024dfe94c913f0c9fa38b3cc3124a72 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 11:10:06 +0200 Subject: [PATCH 07/10] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ture Gjørup --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d598fbe5..95066ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - [#206](https://github.com/os2display/display-api-service/pull/206) - - Added support for Notified feed as replacement for SparkleIOFeedType. + - Added support for Notified (Instagram) feed as replacement for SparkleIOFeedType. - Deprecated SparkleIOFeedType. ## [2.0.4] - 2024-04-25 From c0b3509d4f5dbe46f53f29577ef99ae1600b42f1 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 11:10:13 +0200 Subject: [PATCH 08/10] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ture Gjørup --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95066ffc..ec3962d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. - [#206](https://github.com/os2display/display-api-service/pull/206) - Added support for Notified (Instagram) feed as replacement for SparkleIOFeedType. - - Deprecated SparkleIOFeedType. + - Deprecated SparkleIOFeedType. (getsparkle.io has shut down) ## [2.0.4] - 2024-04-25 From 37e7fc14aa2701aebfaddbf4c31ccfe0749d145a Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 11:21:49 +0200 Subject: [PATCH 09/10] 1203: Fixed issues raised in review --- fixtures/feed.yaml | 32 ++++++++--------- fixtures/feed_source.yaml | 42 +++++++++++----------- fixtures/slide.yaml | 66 +++++++++++++++++------------------ fixtures/template.yaml | 28 +++++++-------- src/Feed/NotifiedFeedType.php | 6 ++-- 5 files changed, 87 insertions(+), 87 deletions(-) diff --git a/fixtures/feed.yaml b/fixtures/feed.yaml index 117d2807..763e1e93 100644 --- a/fixtures/feed.yaml +++ b/fixtures/feed.yaml @@ -1,18 +1,18 @@ --- App\Entity\Tenant\Feed: - feed_abc_1: - feedSource: '@feed_source_abc_1' - slide: '@slide_abc_1' - tenant: '@tenant_abc' - createdAt (unique): '' - modifiedAt: '' - id: '' - feed_abc_notified: - feedSource: '@feed_source_abc_notified' - slide: '@slide_abc_notified' - tenant: '@tenant_abc' - createdAt (unique): '' - modifiedAt: '' - id: '' - configuration: - feeds: [12345] + feed_abc_1: + feedSource: '@feed_source_abc_1' + slide: '@slide_abc_1' + tenant: '@tenant_abc' + createdAt (unique): '' + modifiedAt: '' + id: '' + feed_abc_notified: + feedSource: '@feed_source_abc_notified' + slide: '@slide_abc_notified' + tenant: '@tenant_abc' + createdAt (unique): '' + modifiedAt: '' + id: '' + configuration: + feeds: [12345] diff --git a/fixtures/feed_source.yaml b/fixtures/feed_source.yaml index 3a2c3c81..541b851e 100644 --- a/fixtures/feed_source.yaml +++ b/fixtures/feed_source.yaml @@ -1,23 +1,23 @@ --- App\Entity\Tenant\FeedSource: - feed (template): - description: - feedType: "App\\Feed\\RssFeedType" - secrets: [ ] - supportedFeedOutputType: 'rss' - createdAt (unique): '' - modifiedAt: '' - id: '' - feed_source_abc_1 (extends feed): - title: 'feed_source_abc_1' - tenant: '@tenant_abc' - feed_source_xyz_2 (extends feed): - title: 'feed_source_xyz_2' - tenant: '@tenant_xyz' - feed_source_abc_notified (extends feed): - title: 'feed_source_abc_notified' - feedType: "App\\Feed\\RssFeedType" - secrets: - token: '1234567890' - supportedFeedOutputType: 'instagram' - tenant: '@tenant_abc' + feed (template): + description: + feedType: "App\\Feed\\RssFeedType" + secrets: [ ] + supportedFeedOutputType: 'rss' + createdAt (unique): '' + modifiedAt: '' + id: '' + feed_source_abc_1 (extends feed): + title: 'feed_source_abc_1' + tenant: '@tenant_abc' + feed_source_xyz_2 (extends feed): + title: 'feed_source_xyz_2' + tenant: '@tenant_xyz' + feed_source_abc_notified (extends feed): + title: 'feed_source_abc_notified' + feedType: "App\\Feed\\RssFeedType" + secrets: + token: '1234567890' + supportedFeedOutputType: 'instagram' + tenant: '@tenant_abc' diff --git a/fixtures/slide.yaml b/fixtures/slide.yaml index 288b7dbc..32cb958f 100644 --- a/fixtures/slide.yaml +++ b/fixtures/slide.yaml @@ -1,36 +1,36 @@ --- App\Entity\Tenant\Slide: - slide (template): - description: - duration: - template: '@template_image_text' - createdAt (unique): '' - modifiedAt: '' - id: '' + slide (template): + description: + duration: + template: '@template_image_text' + createdAt (unique): '' + modifiedAt: '' + id: '' - slide_abc_1 (extends slide): - title: 'slide_abc_1' - theme: '@theme_abc_1' - feed: '@feed_abc_1' - tenant: '@tenant_abc' - media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] - slide_abc_{2..60} (extends slide): - title: 'slide_abc_' - theme: '@theme_abc_*' - tenant: '@tenant_abc' - media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] - slide_def_shared_to_abc (extends slide): - title: 'slide_def_shared_to_abc' - theme: '@theme_def' - tenant: '@tenant_def' - media: [ '@media_def_shared_to_abc' ] - slide_xyz_{1..60} (extends slide): - title: 'slide_xyz_' - theme: '@theme_xyz' - tenant: '@tenant_xyz' - slide_abc_notified (extends slide): - title: 'slide_abc_notified' - template: '@template_notified' - content: - maxEntries: 6 - tenant: '@tenant_abc' + slide_abc_1 (extends slide): + title: 'slide_abc_1' + theme: '@theme_abc_1' + feed: '@feed_abc_1' + tenant: '@tenant_abc' + media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] + slide_abc_{2..60} (extends slide): + title: 'slide_abc_' + theme: '@theme_abc_*' + tenant: '@tenant_abc' + media: [ '@media_abc_*', '@media_abc_*', '@media_abc_*' ] + slide_def_shared_to_abc (extends slide): + title: 'slide_def_shared_to_abc' + theme: '@theme_def' + tenant: '@tenant_def' + media: [ '@media_def_shared_to_abc' ] + slide_xyz_{1..60} (extends slide): + title: 'slide_xyz_' + theme: '@theme_xyz' + tenant: '@tenant_xyz' + slide_abc_notified (extends slide): + title: 'slide_abc_notified' + template: '@template_notified' + content: + maxEntries: 6 + tenant: '@tenant_abc' diff --git a/fixtures/template.yaml b/fixtures/template.yaml index 843845f0..f35c4801 100644 --- a/fixtures/template.yaml +++ b/fixtures/template.yaml @@ -1,16 +1,16 @@ --- App\Entity\Template: - template_image_text: - title: 'template_image_text' - description: A template with different formats of image and text - resources: - createdAt (unique): '' - modifiedAt: '' - id: '' - template_notified: - title: 'template_notified' - description: A template with different that serves notified data - resources: - createdAt (unique): '' - modifiedAt: '' - id: '' + template_image_text: + title: 'template_image_text' + description: A template with different formats of image and text + resources: + createdAt (unique): '' + modifiedAt: '' + id: '' + template_notified: + title: 'template_notified' + description: A template with different that serves notified data + resources: + createdAt (unique): '' + modifiedAt: '' + id: '' diff --git a/src/Feed/NotifiedFeedType.php b/src/Feed/NotifiedFeedType.php index ebdc211d..bfa52e5a 100644 --- a/src/Feed/NotifiedFeedType.php +++ b/src/Feed/NotifiedFeedType.php @@ -17,10 +17,10 @@ */ class NotifiedFeedType implements FeedTypeInterface { - final public const SUPPORTED_FEED_TYPE = 'instagram'; - final public const REQUEST_TIMEOUT = 10; + final public const string SUPPORTED_FEED_TYPE = 'instagram'; + final public const int REQUEST_TIMEOUT = 10; - private const BASE_URL = 'https://api.listen.notified.com'; + private const string BASE_URL = 'https://api.listen.notified.com'; public function __construct( private readonly FeedService $feedService, From a4bec38bfff0349277440a7a1b5606c3eea959f2 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Tue, 21 May 2024 10:17:23 +0200 Subject: [PATCH 10/10] 1453: Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3962d7..0a4ed37f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [2.0.5] - 2024-05-21 + - [#206](https://github.com/os2display/display-api-service/pull/206) - Added support for Notified (Instagram) feed as replacement for SparkleIOFeedType. - Deprecated SparkleIOFeedType. (getsparkle.io has shut down)