nostr events added

This commit is contained in:
HolgerHatGarKeineNode
2023-02-24 10:35:07 +01:00
parent 1aaa955567
commit 38a2b63e3f
11 changed files with 167 additions and 212 deletions

View File

@@ -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());
}
}