From da95e9b9ea43aa94a9ac3a5bf48ad3a466caf5c6 Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Fri, 20 Jan 2023 15:02:44 +0100 Subject: [PATCH] news twitter --- app/Observers/LibraryItemObserver.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Observers/LibraryItemObserver.php b/app/Observers/LibraryItemObserver.php index 13a4ac4f..c0040722 100644 --- a/app/Observers/LibraryItemObserver.php +++ b/app/Observers/LibraryItemObserver.php @@ -22,20 +22,31 @@ class LibraryItemObserver $libraryItem->setStatus('published'); $libraryItemName = $libraryItem->name; - if ($libraryItem->lecturer->twitter_username) { + if ($libraryItem->lecturer->twitter_username && $libraryItem->type !== 'markdown_article') { $libraryItemName .= ' von @'.$libraryItem->lecturer->twitter_username; } + if ($libraryItem->lecturer->twitter_username && $libraryItem->type === 'markdown_article') { + $libraryItemName .= ' von '.$libraryItem->lecturer->name; + } if (config('feeds.services.twitterAccountId')) { $this->setNewAccessToken(1); // http://localhost/de/library/library-item?l=de&table[filters][id]=2 - $text = sprintf("Es gibt was Neues zum Anschauen oder Anhören:\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld", - $libraryItemName, - url()->route('library.table.libraryItems', - ['country' => 'de', 'library_items' => ['filters' => ['id' => $libraryItem->id]]]), - ); + if ($libraryItem->type !== 'markdown_article') { + $text = sprintf("Es gibt was Neues zum Anschauen oder Anhören:\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld", + $libraryItemName, + url()->route('library.table.libraryItems', + ['country' => 'de', 'library_items' => ['filters' => ['id' => $libraryItem->id]]]), + ); + } else { + $text = sprintf("Ein neuer News-Artikel wurde verfasst:\n\n%s\n\n%s\n\n#Bitcoin #News #Einundzwanzig #gesundesgeld", + $libraryItemName, + url()->route('article.view', + ['libraryItem' => $libraryItem->slug]), + ); + } $this->postTweet($text); }