mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
nostr events added
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\BitcoinEvent;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BitcoinEventObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the BitcoinEvent "created" event.
|
||||
*/
|
||||
public function created(BitcoinEvent $bitcoinEvent): void
|
||||
{
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
try {
|
||||
$text = sprintf("Ein neues Event wurde eingestellt:\n\n%s\n\n%s bis %s\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld",
|
||||
$bitcoinEvent->title,
|
||||
$bitcoinEvent->from->asDateTime(),
|
||||
@@ -24,8 +24,9 @@ class BitcoinEventObserver
|
||||
$bitcoinEvent->venue->name,
|
||||
$bitcoinEvent->link,
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
$this->publishOnNostr($bitcoinEvent, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\CourseEvent;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CourseEventObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the CourseEvent "created" event.
|
||||
*/
|
||||
public function created(CourseEvent $courseEvent): void
|
||||
{
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
try {
|
||||
$text = sprintf("Unser Dozent %s hat einen neuen Kurs-Termin eingestellt:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Kurs #Education #Einundzwanzig #gesundesgeld",
|
||||
$courseEvent->course->lecturer->name,
|
||||
$courseEvent->course->name,
|
||||
@@ -25,7 +25,9 @@ class CourseEventObserver
|
||||
['country' => 'de', 'lecturer' => $courseEvent->course->lecturer]),
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
$this->publishOnNostr($courseEvent, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Course;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CourseObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the Course "created" event.
|
||||
*/
|
||||
public function created(Course $course): void
|
||||
{
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
try {
|
||||
$text = sprintf("Unser Dozent %s hat einen neuen Kurs eingestellt:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Kurs #Education #Einundzwanzig #gesundesgeld",
|
||||
$course->lecturer->name,
|
||||
$course->name,
|
||||
@@ -25,7 +25,9 @@ class CourseObserver
|
||||
['country' => 'de', 'lecturer' => $course->lecturer]),
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
$this->publishOnNostr($course, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\CourseEvent;
|
||||
|
||||
class EventObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Event "created" event.
|
||||
*/
|
||||
public function created(CourseEvent $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Event "updated" event.
|
||||
*/
|
||||
public function updated(CourseEvent $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Event "deleted" event.
|
||||
*/
|
||||
public function deleted(CourseEvent $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Event "restored" event.
|
||||
*/
|
||||
public function restored(CourseEvent $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Event "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(CourseEvent $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -2,50 +2,41 @@
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Enums\LibraryItemType;
|
||||
use App\Models\LibraryItem;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LibraryItemObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the LibraryItem "created" event.
|
||||
*/
|
||||
public function created(LibraryItem $libraryItem): void
|
||||
{
|
||||
// todo: we can change this later
|
||||
try {
|
||||
$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;
|
||||
}
|
||||
$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
|
||||
|
||||
if ($libraryItem->type !== 'markdown_article') {
|
||||
if ($libraryItem->whereDoesntHave('libraries',
|
||||
fn ($query) => $query->where('libraries.is_public', false))
|
||||
->exists()) {
|
||||
$text = sprintf("Es gibt was Neues zum Lesen oder Anhören:\n\n%s\n\n%s\n\n#Bitcoin #Wissen #Einundzwanzig #gesundesgeld",
|
||||
$libraryItemName,
|
||||
url()->route('article.view',
|
||||
['libraryItem' => $libraryItem->slug]),
|
||||
);
|
||||
$this->postTweet($text);
|
||||
}
|
||||
if ($libraryItem->type !== LibraryItemType::MarkdownArticle()) {
|
||||
if ($libraryItem->whereDoesntHave('libraries',
|
||||
fn($query) => $query->where('libraries.is_public', false))
|
||||
->exists()) {
|
||||
$text = sprintf("Es gibt was Neues zum Lesen oder Anhören:\n\n%s\n\n%s\n\n#Bitcoin #Wissen #Einundzwanzig #gesundesgeld",
|
||||
$libraryItemName,
|
||||
url()->route('article.view',
|
||||
['libraryItem' => $libraryItem->slug]),
|
||||
);
|
||||
$this->publishOnNostr($libraryItem, $text);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// todo: log this
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\MeetupEvent;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MeetupEventObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the MeetupEvent "created" event.
|
||||
@@ -16,25 +17,19 @@ class MeetupEventObserver
|
||||
public function created(MeetupEvent $meetupEvent): void
|
||||
{
|
||||
try {
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
$meetupName = $meetupEvent->meetup->name;
|
||||
if ($meetupEvent->meetup->twitter_username) {
|
||||
$meetupName .= ' @'.$meetupEvent->meetup->twitter_username;
|
||||
}
|
||||
|
||||
$text = sprintf("%s hat einen neuen Termin eingestellt:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Meetup #Einundzwanzig #gesundesgeld",
|
||||
$meetupName,
|
||||
$meetupEvent->start->asDateTime(),
|
||||
$meetupEvent->location,
|
||||
url()->route('meetup.event.landing',
|
||||
['country' => 'de', 'meetupEvent' => $meetupEvent->id]),
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
$meetupName = $meetupEvent->meetup->name;
|
||||
if ($meetupEvent->meetup->nostr) {
|
||||
$meetupName .= ' @'.$meetupEvent->meetup->nostr;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$text = sprintf("%s hat einen neuen Termin eingestellt:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Meetup #Einundzwanzig #gesundesgeld",
|
||||
$meetupName,
|
||||
$meetupEvent->start->asDateTime(),
|
||||
$meetupEvent->location,
|
||||
url()->route('meetup.event.landing',
|
||||
['country' => 'de', 'meetupEvent' => $meetupEvent->id]),
|
||||
);
|
||||
$this->publishOnNostr($meetupEvent, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Meetup;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MeetupObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the Meetup "created" event.
|
||||
@@ -16,22 +17,16 @@ class MeetupObserver
|
||||
public function created(Meetup $meetup): void
|
||||
{
|
||||
try {
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
$meetupName = $meetup->name;
|
||||
if ($meetup->twitter_username) {
|
||||
$meetupName .= ' @'.$meetup->twitter_username;
|
||||
}
|
||||
|
||||
$text = sprintf("Eine neue Meetup Gruppe wurde hinzugefügt:\n\n%s\n\n%s\n\n#Bitcoin #Meetup #Einundzwanzig #gesundesgeld",
|
||||
$meetupName,
|
||||
url()->route('meetup.landing', ['country' => $meetup->city->country->code, 'meetup' => $meetup])
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
$meetupName = $meetup->name;
|
||||
if ($meetup->nostr) {
|
||||
$meetupName .= ' @'.$meetup->nostr;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$text = sprintf("Eine neue Meetup Gruppe wurde hinzugefügt:\n\n%s\n\n%s\n\n#Bitcoin #Meetup #Einundzwanzig #gesundesgeld",
|
||||
$meetupName,
|
||||
url()->route('meetup.landing', ['country' => $meetup->city->country->code, 'meetup' => $meetup])
|
||||
);
|
||||
$this->publishOnNostr($meetup, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,29 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\OrangePill;
|
||||
use App\Traits\TwitterTrait;
|
||||
use App\Traits\NostrTrait;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OrangePillObserver
|
||||
{
|
||||
use TwitterTrait;
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* Handle the OrangePill "created" event.
|
||||
*/
|
||||
public function created(OrangePill $orangePill): void
|
||||
{
|
||||
// if (config('feeds.services.twitterAccountId')) {
|
||||
// $this->setNewAccessToken(1);
|
||||
//
|
||||
// $text = sprintf("Ein neues Bitcoin-Buch liegt nun in diesem öffentlichen Bücherschrank:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Education #Einundzwanzig #gesundesgeld",
|
||||
// $orangePill->bookCase->title,
|
||||
// $orangePill->bookCase->address,
|
||||
// url()->route('bookCases.comment.bookcase', ['country' => 'de', 'bookCase' => $orangePill->bookCase]),
|
||||
// );
|
||||
//
|
||||
// $this->postTweet($text);
|
||||
// }
|
||||
try {
|
||||
$text = sprintf("Ein neues Bitcoin-Buch liegt nun in diesem öffentlichen Bücherschrank:\n\n%s\n\n%s\n\n%s\n\n#Bitcoin #Education #Einundzwanzig #gesundesgeld",
|
||||
$orangePill->bookCase->title,
|
||||
$orangePill->bookCase->address,
|
||||
url()->route('bookCases.comment.bookcase', ['country' => 'de', 'bookCase' => $orangePill->bookCase]),
|
||||
);
|
||||
$this->publishOnNostr($orangePill, $text);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user