news twitter

This commit is contained in:
Benjamin Takats
2023-01-20 15:02:44 +01:00
parent 1dbb7651e1
commit da95e9b9ea

View File

@@ -22,20 +22,31 @@ class LibraryItemObserver
$libraryItem->setStatus('published'); $libraryItem->setStatus('published');
$libraryItemName = $libraryItem->name; $libraryItemName = $libraryItem->name;
if ($libraryItem->lecturer->twitter_username) { if ($libraryItem->lecturer->twitter_username && $libraryItem->type !== 'markdown_article') {
$libraryItemName .= ' von @'.$libraryItem->lecturer->twitter_username; $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')) { if (config('feeds.services.twitterAccountId')) {
$this->setNewAccessToken(1); $this->setNewAccessToken(1);
// http://localhost/de/library/library-item?l=de&table[filters][id]=2 // 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", if ($libraryItem->type !== 'markdown_article') {
$libraryItemName, $text = sprintf("Es gibt was Neues zum Anschauen oder Anhören:\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld",
url()->route('library.table.libraryItems', $libraryItemName,
['country' => 'de', 'library_items' => ['filters' => ['id' => $libraryItem->id]]]), 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); $this->postTweet($text);
} }