nostr events added

This commit is contained in:
HolgerHatGarKeineNode
2023-02-24 11:13:43 +01:00
parent 5fbef7d4aa
commit 235ce774f9
10 changed files with 119 additions and 105 deletions

View File

@@ -17,14 +17,7 @@ class BitcoinEventObserver
public function created(BitcoinEvent $bitcoinEvent): void
{
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(),
$bitcoinEvent->to->asDateTime(),
$bitcoinEvent->venue->name,
$bitcoinEvent->link,
);
$this->publishOnNostr($bitcoinEvent, $text);
$this->publishOnNostr($bitcoinEvent, $this->getText('BitcoinEvent'));
} catch (Exception $e) {
Log::error($e->getMessage());
}

View File

@@ -17,15 +17,7 @@ class CourseEventObserver
public function created(CourseEvent $courseEvent): void
{
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,
str($courseEvent->course->description)->limit(80),
url()->route('school.landingPage.lecturer',
['country' => 'de', 'lecturer' => $courseEvent->course->lecturer]),
);
$this->publishOnNostr($courseEvent, $text);
$this->publishOnNostr($courseEvent, $this->getText('CourseEvent'));
} catch (Exception $e) {
Log::error($e->getMessage());
}

View File

@@ -17,15 +17,7 @@ class CourseObserver
public function created(Course $course): void
{
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,
str($course->description)->limit(80),
url()->route('school.landingPage.lecturer',
['country' => 'de', 'lecturer' => $course->lecturer]),
);
$this->publishOnNostr($course, $text);
$this->publishOnNostr($course, $this->getText('Course'));
} catch (Exception $e) {
Log::error($e->getMessage());
}

View File

@@ -1,48 +0,0 @@
<?php
namespace App\Observers;
use App\Models\Episode;
class EpisodeObserver
{
/**
* Handle the Episode "created" event.
*/
public function created(Episode $episode): void
{
//
}
/**
* Handle the Episode "updated" event.
*/
public function updated(Episode $episode): void
{
//
}
/**
* Handle the Episode "deleted" event.
*/
public function deleted(Episode $episode): void
{
//
}
/**
* Handle the Episode "restored" event.
*/
public function restored(Episode $episode): void
{
//
}
/**
* Handle the Episode "force deleted" event.
*/
public function forceDeleted(Episode $episode): void
{
//
}
}

View File

@@ -20,19 +20,14 @@ class LibraryItemObserver
try {
$libraryItem->setStatus('published');
$libraryItemName = $libraryItem->name;
$libraryItemName .= ' von '.$libraryItem->lecturer->name;
$from = $libraryItem->name;
$from .= ' von '.$libraryItem->lecturer->name;
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);
$this->publishOnNostr($libraryItem, $this->getText('LibraryItem', $from));
}
}
} catch (Exception $e) {

View File

@@ -17,18 +17,11 @@ class MeetupEventObserver
public function created(MeetupEvent $meetupEvent): void
{
try {
$meetupName = $meetupEvent->meetup->name;
$from = $meetupEvent->meetup->name;
if ($meetupEvent->meetup->nostr) {
$meetupName .= ' @'.$meetupEvent->meetup->nostr;
$from .= ' @'.$meetupEvent->meetup->nostr;
}
$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);
$this->publishOnNostr($meetupEvent, $this->getText('MeetupEvent', $from));
} catch (Exception $e) {
Log::error($e->getMessage());
}

View File

@@ -17,15 +17,11 @@ class MeetupObserver
public function created(Meetup $meetup): void
{
try {
$meetupName = $meetup->name;
$from = $meetup->name;
if ($meetup->nostr) {
$meetupName .= ' @'.$meetup->nostr;
$from .= ' @'.$meetup->nostr;
}
$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);
$this->publishOnNostr($meetup, $this->getText('Meetup', $from));
} catch (Exception $e) {
Log::error($e->getMessage());
}

View File

@@ -17,12 +17,7 @@ class OrangePillObserver
public function created(OrangePill $orangePill): void
{
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);
$this->publishOnNostr($orangePill, $this->getText('OrangePill'));
} catch (Exception $e) {
Log::error($e->getMessage());
}