diff --git a/frontend/src/components/Stations/Webhooks/EditModal.vue b/frontend/src/components/Stations/Webhooks/EditModal.vue index 4138eb564..26471f80c 100644 --- a/frontend/src/components/Stations/Webhooks/EditModal.vue +++ b/frontend/src/components/Stations/Webhooks/EditModal.vue @@ -50,6 +50,7 @@ import {getTriggers, WebhookType} from "~/entities/Webhooks"; import Tabs from "~/components/Common/Tabs.vue"; import RadioDe from "~/components/Stations/Webhooks/Form/RadioDe.vue"; import GetMeRadio from "~/components/Stations/Webhooks/Form/GetMeRadio.vue"; +import RadioReg from "~/components/Stations/Webhooks/Form/RadioReg.vue"; const props = defineProps({ ...baseEditModalProps, @@ -80,6 +81,7 @@ const webhookComponents = { [WebhookType.Email]: Email, [WebhookType.TuneIn]: Tunein, [WebhookType.RadioDe]: RadioDe, + [WebhookType.RadioReg]: RadioReg, [WebhookType.GetMeRadio]: GetMeRadio, [WebhookType.Discord]: Discord, [WebhookType.Telegram]: Telegram, diff --git a/frontend/src/components/Stations/Webhooks/Form/RadioReg.vue b/frontend/src/components/Stations/Webhooks/Form/RadioReg.vue new file mode 100644 index 000000000..6661b04db --- /dev/null +++ b/frontend/src/components/Stations/Webhooks/Form/RadioReg.vue @@ -0,0 +1,60 @@ + + + diff --git a/frontend/src/components/Stations/Webhooks/Form/TypeSelect.vue b/frontend/src/components/Stations/Webhooks/Form/TypeSelect.vue index ed3c8b88b..d71380689 100644 --- a/frontend/src/components/Stations/Webhooks/Form/TypeSelect.vue +++ b/frontend/src/components/Stations/Webhooks/Form/TypeSelect.vue @@ -26,6 +26,7 @@ :types="buildTypeInfo([ WebhookType.TuneIn, WebhookType.RadioDe, + WebhookType.RadioReg, WebhookType.GetMeRadio ])" @select="selectType" diff --git a/frontend/src/entities/Webhooks.ts b/frontend/src/entities/Webhooks.ts index b0179dc97..58e5d0608 100644 --- a/frontend/src/entities/Webhooks.ts +++ b/frontend/src/entities/Webhooks.ts @@ -75,6 +75,7 @@ export enum WebhookType { Email = 'email', TuneIn = 'tunein', RadioDe = 'radiode', + RadioReg = 'radioreg', GetMeRadio = 'getmeradio', Discord = 'discord', Telegram = 'telegram', @@ -103,6 +104,10 @@ export function useTypeDetails() { title: $gettext('Radio.de'), description: $gettext('Send song metadata changes to %{service}.', {service: 'Radio.de'}) }, + [WebhookType.RadioReg]: { + title: $gettext('RadioReg.net'), + description: $gettext('Send song metadata changes to %{service}.', {service: 'RadioReg'}) + }, [WebhookType.GetMeRadio]: { title: $gettext('GetMeRadio'), description: $gettext('Send song metadata changes to %{service}', {service: 'GetMeRadio'}) @@ -134,6 +139,7 @@ export function getTriggers(type: WebhookType) { switch(type) { case WebhookType.TuneIn: case WebhookType.RadioDe: + case WebhookType.RadioReg: case WebhookType.GetMeRadio: case WebhookType.GoogleAnalyticsV4: case WebhookType.MatomoAnalytics: diff --git a/src/Webhook/Connector/RadioReg.php b/src/Webhook/Connector/RadioReg.php new file mode 100644 index 000000000..d411ad70a --- /dev/null +++ b/src/Webhook/Connector/RadioReg.php @@ -0,0 +1,56 @@ +value, $triggers, true); + } + + /** + * @optischa + */ + public function dispatch( + Station $station, + StationWebhook $webhook, + NowPlaying $np, + array $triggers + ): void { + $config = $webhook->getConfig(); + + if ( + empty($config['apikey']) || empty($config['webhookurl']) + ) { + throw $this->incompleteConfigException($webhook); + } + + $this->logger->debug('Dispatching RadioReg API call...'); + + $messageBody = [ + 'title' => $np->now_playing?->song?->title, + 'artist' => $np->now_playing?->song?->artist, + ]; + + $response = $this->httpClient->post( + $config['webhookurl'], + [ + 'query' => $messageBody, + 'headers' => [ + 'Accept' => 'application/json', + 'X-API-KEY' => $config['apikey'], + ], + ], + ); + + $this->logHttpResponse($webhook, $response, $messageBody); + } +} diff --git a/src/Webhook/Enums/WebhookTypes.php b/src/Webhook/Enums/WebhookTypes.php index 826b2c02d..8df5cf47d 100644 --- a/src/Webhook/Enums/WebhookTypes.php +++ b/src/Webhook/Enums/WebhookTypes.php @@ -12,6 +12,7 @@ use App\Webhook\Connector\GoogleAnalyticsV4; use App\Webhook\Connector\Mastodon; use App\Webhook\Connector\MatomoAnalytics; use App\Webhook\Connector\RadioDe; +use App\Webhook\Connector\RadioReg; use App\Webhook\Connector\Telegram; use App\Webhook\Connector\TuneIn; @@ -22,6 +23,7 @@ enum WebhookTypes: string case TuneIn = 'tunein'; case RadioDe = 'radiode'; + case RadioReg = 'radioreg'; case GetMeRadio = 'getmeradio'; case Discord = 'discord'; @@ -44,6 +46,7 @@ enum WebhookTypes: string self::Generic => Generic::class, self::Email => Email::class, self::TuneIn => TuneIn::class, + self::RadioReg => RadioReg::class, self::RadioDe => RadioDe::class, self::GetMeRadio => GetMeRadio::class, self::Discord => Discord::class,