with([ 'lecturer', ]) ->find($id); if ($libraryItem->tweet) { $this->notification() ->error(__('Article already tweeted')); return; } $libraryItem->setStatus('published'); $libraryItemName = $libraryItem->name; if ($libraryItem->lecturer->twitter_username && $libraryItem->type !== 'markdown_article') { $libraryItemName .= ' von @'.$libraryItem->lecturer->twitter_username; } if (!$libraryItem->lecturer->twitter_username) { $libraryItemName .= ' von '.$libraryItem->lecturer->name; } try { if (config('feeds.services.twitterAccountId')) { $this->setNewAccessToken(1); if (!$libraryItem->approved) { $this->notification() ->error(__('Article not approved yet')); return; } $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); $libraryItem->tweet = true; $libraryItem->save(); $this->notification() ->success(__('Article tweeted')); $this->emit('$refresh'); } } catch (\Exception $e) { $this->notification() ->error(__('Error tweeting article', $e->getMessage())); } } public function nostr($id) { $libraryItem = LibraryItem::query() ->with([ 'lecturer', ]) ->find($id); $libraryItem->setStatus('published'); $libraryItemName = $libraryItem->name; if (!$libraryItem->lecturer->nostr) { $libraryItemName .= ' von @'.$libraryItem->nostr->name; } else { $libraryItemName .= ' von '.$libraryItem->lecturer->name; } $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]), ); //noscl publish "Good morning!" $result = Process::run('noscl publish "'.$text.'"'); if ($result->successful()) { $libraryItem->nostr = $result->output(); $libraryItem->save(); $this->notification() ->success(title: __('Published on Nostr'), description: $result->output()); } if ($result->failed()) { $this->notification() ->error(title: __('Failed'), description: 'Exit Code: '.$result->exitCode().' Reason: '.$result->errorOutput()); } } public function approve($id) { $libraryItem = LibraryItem::find($id); $libraryItem->approved = true; $libraryItem->save(); $this->notification() ->success(__('Article approved')); $this->emit('$refresh'); } public function render() { return view('livewire.news.article-overview', [ 'libraryItems' => LibraryItem::query() ->with([ 'createdBy.roles', 'lecturer', 'tags', ]) ->where('type', 'markdown_article') ->where('news', true) ->orderByDesc('created_at') ->get(), ])->layout('layouts.app', [ 'SEOData' => new SEOData( title: __('News'), description: __('Here we post important news that is relevant for everyone.'), image: asset('img/einundzwanzig-news-colored.png'), ), ]); } }