mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-26 05:23:19 +00:00
🛠️ Refactor migrations, models, configs, and Blade files to apply consistent formatting, remove unnecessary lines, and improve readability.
This commit is contained in:
@@ -7,6 +7,7 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||
class NostrUser implements Authenticatable
|
||||
{
|
||||
protected string $pubkey;
|
||||
|
||||
protected ?object $pleb;
|
||||
|
||||
public function __construct(string $pubkey)
|
||||
|
||||
@@ -36,7 +36,7 @@ class SyncPlebs extends Command
|
||||
$npub = str($pleb)->trim();
|
||||
EinundzwanzigPleb::updateOrCreate(
|
||||
['npub' => $npub],
|
||||
['pubkey' => (new Key())->convertToHex($npub)]
|
||||
['pubkey' => (new Key)->convertToHex($npub)]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ class FetchEvents extends Command
|
||||
$plebs = \App\Models\EinundzwanzigPleb::query()
|
||||
->get();
|
||||
|
||||
$subscription = new Subscription();
|
||||
$subscription = new Subscription;
|
||||
$subscriptionId = $subscription->setId();
|
||||
|
||||
$filter1 = new Filter();
|
||||
$filter1 = new Filter;
|
||||
$filter1->setKinds([1]); // You can add multiple kind numbers
|
||||
$filter1->setAuthors($plebs->pluck('pubkey')->toArray()); // You can add multiple authors
|
||||
$filter1->setLimit(25); // Limit to fetch only a maximum of 25 events
|
||||
@@ -54,7 +54,7 @@ class FetchEvents extends Command
|
||||
new Relay('wss://nostr.wine'),
|
||||
new Relay('wss://nos.lol'),
|
||||
];
|
||||
$relaySet = new RelaySet();
|
||||
$relaySet = new RelaySet;
|
||||
$relaySet->setRelays($relays);
|
||||
|
||||
$request = new Request($relaySet, $requestMessage);
|
||||
@@ -64,7 +64,7 @@ class FetchEvents extends Command
|
||||
|
||||
foreach ($response as $relay => $events) {
|
||||
foreach ($events as $event) {
|
||||
if (!isset($uniqueEvents[$event->event->id])) {
|
||||
if (! isset($uniqueEvents[$event->event->id])) {
|
||||
$uniqueEvents[$event->event->id] = $event;
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,7 @@ class FetchEvents extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -104,11 +105,12 @@ class FetchEvents extends Command
|
||||
{
|
||||
foreach ($event->tags as $tag) {
|
||||
if ($tag[0] === 'e') {
|
||||
if ((isset($tag[3]) && $tag[3] === 'reply') || (!isset($tag[3]) && isset($tag[2]) && $tag[2] === '')) {
|
||||
if ((isset($tag[3]) && $tag[3] === 'reply') || (! isset($tag[3]) && isset($tag[2]) && $tag[2] === '')) {
|
||||
return 'reply';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'root';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class FetchProfile extends Command
|
||||
$pubkey = $this->option('pubkey');
|
||||
if (empty($pubkey)) {
|
||||
$this->error('Please provide a pubkey');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class SyncProfiles extends Command
|
||||
{
|
||||
$query = EinundzwanzigPleb::query();
|
||||
|
||||
if (!$this->option('all')) {
|
||||
if (! $this->option('all')) {
|
||||
$query->whereDoesntHave('profile');
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class SyncProfiles extends Command
|
||||
$bar->finish();
|
||||
$this->info("\n✅ Successfully synced $count profiles!");
|
||||
} else {
|
||||
$this->info("⚡ No profiles to sync!");
|
||||
$this->info('⚡ No profiles to sync!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ use ArchTech\Enums\Values;
|
||||
#[Meta(Label::class, Color::class)]
|
||||
enum AssociationStatus: int
|
||||
{
|
||||
use InvokableCases;
|
||||
use Names;
|
||||
use Values;
|
||||
use Options;
|
||||
use Metadata;
|
||||
use From;
|
||||
use InvokableCases;
|
||||
use Metadata;
|
||||
use Names;
|
||||
use Options;
|
||||
use Values;
|
||||
|
||||
#[Label('kein Mitglied')] #[Color('cyan')]
|
||||
case DEFAULT = 1;
|
||||
@@ -33,7 +33,7 @@ enum AssociationStatus: int
|
||||
{
|
||||
return collect(self::options())
|
||||
->map(
|
||||
fn(
|
||||
fn (
|
||||
$option,
|
||||
$name
|
||||
) => [
|
||||
|
||||
@@ -6,6 +6,4 @@ use ArchTech\Enums\Meta\MetaProperty;
|
||||
use Attribute;
|
||||
|
||||
#[Attribute]
|
||||
class Color extends MetaProperty
|
||||
{
|
||||
}
|
||||
class Color extends MetaProperty {}
|
||||
|
||||
@@ -6,6 +6,4 @@ use ArchTech\Enums\Meta\MetaProperty;
|
||||
use Attribute;
|
||||
|
||||
#[Attribute]
|
||||
class Icon extends MetaProperty
|
||||
{
|
||||
}
|
||||
class Icon extends MetaProperty {}
|
||||
|
||||
@@ -6,6 +6,4 @@ use ArchTech\Enums\Meta\MetaProperty;
|
||||
use Attribute;
|
||||
|
||||
#[Attribute]
|
||||
class Label extends MetaProperty
|
||||
{
|
||||
}
|
||||
class Label extends MetaProperty {}
|
||||
|
||||
@@ -13,12 +13,12 @@ use ArchTech\Enums\Values;
|
||||
#[Meta(Label::class, Color::class, Icon::class)]
|
||||
enum NewsCategory: int
|
||||
{
|
||||
use InvokableCases;
|
||||
use Names;
|
||||
use Values;
|
||||
use Options;
|
||||
use Metadata;
|
||||
use From;
|
||||
use InvokableCases;
|
||||
use Metadata;
|
||||
use Names;
|
||||
use Options;
|
||||
use Values;
|
||||
|
||||
#[Label('Organisation')] #[Color('cyan')] #[Icon('file-lines')]
|
||||
case ORGANISATION = 1;
|
||||
@@ -27,7 +27,7 @@ enum NewsCategory: int
|
||||
{
|
||||
return collect(self::options())
|
||||
->map(
|
||||
fn(
|
||||
fn (
|
||||
$option,
|
||||
$name
|
||||
) => [
|
||||
|
||||
@@ -15,7 +15,7 @@ class GetProfile extends Controller
|
||||
|
||||
public function __invoke($key, Request $request)
|
||||
{
|
||||
if (!Profile::query()->where('pubkey', $key)->exists()) {
|
||||
if (! Profile::query()->where('pubkey', $key)->exists()) {
|
||||
$this->fetchProfile([$key]);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class GetProfile extends Controller
|
||||
->where('pubkey', $key)
|
||||
->first();
|
||||
|
||||
if (!$profile) {
|
||||
if (! $profile) {
|
||||
return response()->json(['message' => 'Profile not found'], 200);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class ApplicationForm extends Form
|
||||
{
|
||||
#[Validate('nullable|string')]
|
||||
public $reason = '';
|
||||
|
||||
#[Validate('boolean')]
|
||||
public $check = false;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,9 @@ use PowerComponents\LivewirePowerGrid\Exportable;
|
||||
use PowerComponents\LivewirePowerGrid\Facades\Filter;
|
||||
use PowerComponents\LivewirePowerGrid\Facades\Rule;
|
||||
use PowerComponents\LivewirePowerGrid\Footer;
|
||||
use PowerComponents\LivewirePowerGrid\Header;
|
||||
use PowerComponents\LivewirePowerGrid\Lazy;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGrid;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGridFields;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
|
||||
use PowerComponents\LivewirePowerGrid\PowerGridFields;
|
||||
|
||||
final class MeetupTable extends PowerGridComponent
|
||||
{
|
||||
@@ -54,7 +52,7 @@ final class MeetupTable extends PowerGridComponent
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Column::action('Action')
|
||||
Column::action('Action'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,7 +77,7 @@ final class MeetupTable extends PowerGridComponent
|
||||
->slot('Edit: '.$row->id)
|
||||
->id()
|
||||
->class('pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hover:bg-pg-primary-700 dark:ring-offset-pg-primary-800 dark:text-pg-primary-300 dark:bg-pg-primary-700')
|
||||
->dispatch('edit', ['rowId' => $row->id])
|
||||
->dispatch('edit', ['rowId' => $row->id]),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,11 @@ use Livewire\Attributes\On;
|
||||
trait WithNostrAuth
|
||||
{
|
||||
public ?string $currentPubkey = null;
|
||||
|
||||
public ?object $currentPleb = null;
|
||||
|
||||
public bool $isAllowed = false;
|
||||
|
||||
public bool $canEdit = false;
|
||||
|
||||
#[On('nostrLoggedIn')]
|
||||
|
||||
@@ -12,8 +12,8 @@ use Spatie\Sluggable\SlugOptions;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
use HasSlug;
|
||||
use Geoly;
|
||||
use HasSlug;
|
||||
|
||||
protected $connection = 'einundzwanzig';
|
||||
|
||||
@@ -51,9 +51,9 @@ class City extends Model
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom(['country.code', 'name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
->generateSlugsFrom(['country.code', 'name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
|
||||
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Spatie\Image\Enums\Fit;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
@@ -15,8 +14,8 @@ use Spatie\Tags\HasTags;
|
||||
|
||||
class Course extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
use HasTags;
|
||||
use InteractsWithMedia;
|
||||
|
||||
protected $connection = 'einundzwanzig';
|
||||
|
||||
@@ -46,25 +45,25 @@ class Course extends Model implements HasMedia
|
||||
});
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
->fit(Fit::Crop, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('logo')
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
$this->addMediaCollection('images')
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CourseEvent extends Model
|
||||
{
|
||||
|
||||
@@ -38,5 +38,4 @@ class EinundzwanzigPleb extends Model implements CipherSweetEncrypted
|
||||
{
|
||||
return $this->hasMany(PaymentEvent::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function renderedEvent()
|
||||
{
|
||||
return $this->hasOne(RenderedEvent::class, 'event_id', 'event_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,47 +23,49 @@ class Lecturer extends Model implements HasMedia
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'active' => 'boolean',
|
||||
'id' => 'integer',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (!$model->created_by) {
|
||||
if (! $model->created_by) {
|
||||
$model->created_by = auth()->id();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
->fit(Fit::Crop, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('avatar')
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
$this->addMediaCollection('images')
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,9 +74,9 @@ class Lecturer extends Model implements HasMedia
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom(['name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
->generateSlugsFrom(['name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
|
||||
@@ -16,8 +16,8 @@ use Spatie\Sluggable\SlugOptions;
|
||||
|
||||
class Meetup extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
use HasSlug;
|
||||
use InteractsWithMedia;
|
||||
|
||||
protected $connection = 'einundzwanzig';
|
||||
|
||||
@@ -43,7 +43,7 @@ class Meetup extends Model implements HasMedia
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (!$model->created_by) {
|
||||
if (! $model->created_by) {
|
||||
$model->created_by = auth()->id();
|
||||
}
|
||||
});
|
||||
@@ -57,7 +57,7 @@ class Meetup extends Model implements HasMedia
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
@@ -101,7 +101,7 @@ class Meetup extends Model implements HasMedia
|
||||
}
|
||||
|
||||
return Attribute::make(
|
||||
get: fn() => url()->route('img',
|
||||
get: fn () => url()->route('img',
|
||||
[
|
||||
'path' => $path,
|
||||
'w' => 900,
|
||||
@@ -117,7 +117,7 @@ class Meetup extends Model implements HasMedia
|
||||
$nextEvent = $this->meetupEvents()->where('start', '>=', now())->orderBy('start')->first();
|
||||
|
||||
return Attribute::make(
|
||||
get: fn() => $nextEvent ? [
|
||||
get: fn () => $nextEvent ? [
|
||||
'start' => $nextEvent->start->toDateTimeString(),
|
||||
'portalLink' => url()->route('meetup.event.landing', ['country' => $this->city->country, 'meetupEvent' => $nextEvent]),
|
||||
'location' => $nextEvent->location,
|
||||
|
||||
@@ -6,7 +6,5 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Profile extends Model
|
||||
{
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
}
|
||||
|
||||
@@ -15,17 +15,19 @@ use Spatie\Sluggable\SlugOptions;
|
||||
|
||||
class ProjectProposal extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
use HasSlug;
|
||||
use InteractsWithMedia;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
@@ -33,10 +35,7 @@ class ProjectProposal extends Model implements HasMedia
|
||||
'einundzwanzig_pleb_id' => 'integer',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
|
||||
}
|
||||
protected static function booted() {}
|
||||
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
@@ -46,7 +45,7 @@ class ProjectProposal extends Model implements HasMedia
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
|
||||
@@ -16,8 +16,8 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Venue extends Model implements HasMedia
|
||||
{
|
||||
use HasSlug;
|
||||
use HasRelationships;
|
||||
use HasSlug;
|
||||
use InteractsWithMedia;
|
||||
|
||||
protected $connection = 'einundzwanzig';
|
||||
@@ -48,22 +48,22 @@ class Venue extends Model implements HasMedia
|
||||
});
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
->fit(Fit::Crop, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('images')
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,9 +72,9 @@ class Venue extends Model implements HasMedia
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom(['city.slug', 'name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
->generateSlugsFrom(['city.slug', 'name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
@@ -89,12 +89,12 @@ class Venue extends Model implements HasMedia
|
||||
|
||||
public function lecturers()
|
||||
{
|
||||
return $this->hasManyDeepFromRelations($this->courses(), (new Course())->lecturer());
|
||||
return $this->hasManyDeepFromRelations($this->courses(), (new Course)->lecturer());
|
||||
}
|
||||
|
||||
public function courses()
|
||||
{
|
||||
return $this->hasManyDeepFromRelations($this->events(), (new CourseEvent())->course());
|
||||
return $this->hasManyDeepFromRelations($this->events(), (new CourseEvent)->course());
|
||||
}
|
||||
|
||||
public function courseEvents(): HasMany
|
||||
|
||||
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Vote extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
|
||||
@@ -13,7 +13,7 @@ class NostrAuthServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
Auth::provider('nostr', function (Application $app, array $config) {
|
||||
return new NostrUserProvider();
|
||||
return new NostrUserProvider;
|
||||
});
|
||||
|
||||
Auth::extend('nostr-session', function (Application $app, string $name, array $config) {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Support;
|
||||
|
||||
use App\Auth\NostrUser;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class NostrAuth
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ trait NostrEventRendererTrait
|
||||
$profile = Profile::query()->where('pubkey', $event->pubkey)->first();
|
||||
if ($profile && $profile->name) {
|
||||
$name = $profile->name;
|
||||
} elseif ($profile && !empty($profile->display_name)) {
|
||||
} elseif ($profile && ! empty($profile->display_name)) {
|
||||
$name = $profile->display_name;
|
||||
} else {
|
||||
$name = 'Anonymous';
|
||||
@@ -30,7 +30,7 @@ trait NostrEventRendererTrait
|
||||
'event_id' => $event->event_id,
|
||||
], [
|
||||
'html' => $content,
|
||||
'profile_image' => $profile && $profile->picture !== '' ? $profile->picture : 'https://robohash.org/' . $profile->pubkey,
|
||||
'profile_image' => $profile && $profile->picture !== '' ? $profile->picture : 'https://robohash.org/'.$profile->pubkey,
|
||||
'profile_name' => $name,
|
||||
]);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ trait NostrEventRendererTrait
|
||||
$profile = Profile::query()->where('pubkey', $pubkey)->first();
|
||||
if ($profile && $profile->name) {
|
||||
$name = $profile->name;
|
||||
} elseif ($profile && !empty($profile->display_name)) {
|
||||
} elseif ($profile && ! empty($profile->display_name)) {
|
||||
$name = $profile->display_name;
|
||||
} else {
|
||||
$name = 'Anonymous';
|
||||
|
||||
@@ -22,6 +22,7 @@ trait NostrFetcherTrait
|
||||
'hex' => $item,
|
||||
'npub' => (new Key)->convertPublicKeyToBech32($item),
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
$hex->push([
|
||||
@@ -30,10 +31,10 @@ trait NostrFetcherTrait
|
||||
]);
|
||||
}
|
||||
|
||||
$subscription = new Subscription();
|
||||
$subscription = new Subscription;
|
||||
$subscriptionId = $subscription->setId();
|
||||
|
||||
$filter1 = new Filter();
|
||||
$filter1 = new Filter;
|
||||
$filter1->setKinds([0]); // You can add multiple kind numbers
|
||||
$filter1->setAuthors($hex->pluck('hex')->toArray()); // You can add multiple author ids
|
||||
$filters = [$filter1];
|
||||
@@ -54,7 +55,7 @@ trait NostrFetcherTrait
|
||||
try {
|
||||
$response = $request->send();
|
||||
$data = $response[$relayUrl];
|
||||
if (!empty($data)) {
|
||||
if (! empty($data)) {
|
||||
\Log::info('Successfully fetched data from relay: '.$relayUrl);
|
||||
break; // Exit the loop if data is not empty
|
||||
}
|
||||
@@ -65,6 +66,7 @@ trait NostrFetcherTrait
|
||||
|
||||
if (empty($data)) {
|
||||
\Log::warning('No data found from any relay');
|
||||
|
||||
return;
|
||||
}
|
||||
foreach ($data as $item) {
|
||||
@@ -94,5 +96,4 @@ trait NostrFetcherTrait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user