mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
add nostr publishing
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Livewire\News;
|
|||||||
|
|
||||||
use App\Models\LibraryItem;
|
use App\Models\LibraryItem;
|
||||||
use App\Traits\TwitterTrait;
|
use App\Traits\TwitterTrait;
|
||||||
|
use Illuminate\Support\Facades\Process;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||||
use WireUi\Traits\Actions;
|
use WireUi\Traits\Actions;
|
||||||
@@ -68,6 +69,42 @@ class ArticleOverview extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$libraryItem = LibraryItem::find($id);
|
$libraryItem = LibraryItem::find($id);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('library_items', function (Blueprint $table) {
|
||||||
|
$table->text('nostr')
|
||||||
|
->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('library_items', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
WWWGROUP: '${WWWGROUP}'
|
WWWGROUP: '${WWWGROUP}'
|
||||||
|
NOSTR_PRIVATE_KEY: '${NOSTR_PRIVATE_KEY}'
|
||||||
image: sail-8.2/app
|
image: sail-8.2/app
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- 'host.docker.internal:host-gateway'
|
- 'host.docker.internal:host-gateway'
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ FROM ubuntu:22.04
|
|||||||
|
|
||||||
LABEL maintainer="Taylor Otwell"
|
LABEL maintainer="Taylor Otwell"
|
||||||
|
|
||||||
|
ARG NOSTR_PRIVATE_KEY
|
||||||
ARG WWWGROUP
|
ARG WWWGROUP
|
||||||
ARG NODE_VERSION=18
|
ARG NODE_VERSION=18
|
||||||
ARG POSTGRES_VERSION=14
|
ARG POSTGRES_VERSION=14
|
||||||
@@ -14,7 +15,7 @@ ENV TZ=UTC
|
|||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \
|
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils golang wget \
|
||||||
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
|
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
|
||||||
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
|
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
@@ -48,6 +49,14 @@ RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2
|
|||||||
RUN groupadd --force -g $WWWGROUP sail
|
RUN groupadd --force -g $WWWGROUP sail
|
||||||
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
|
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
|
||||||
|
|
||||||
|
RUN wget https://github.com/fiatjaf/noscl/releases/download/v0.6.0/noscl -O /usr/local/bin/noscl \
|
||||||
|
&& chmod +x /usr/local/bin/noscl \
|
||||||
|
&& mkdir -p /home/sail/.config/nostr
|
||||||
|
COPY nostr.json /home/sail/.config/nostr/config.json
|
||||||
|
RUN chown -R sail:sail /home/sail/.config
|
||||||
|
RUN sed -i 's/NOSTR_PRIVATE_KEY/'"$NOSTR_PRIVATE_KEY"'/g' /home/sail/.config/nostr/config.json
|
||||||
|
# noscl publish "Publish event from https://portal.einundzwanzig.portal - developing a bot for Einundzwanzig Portal"
|
||||||
|
|
||||||
COPY start-container /usr/local/bin/start-container
|
COPY start-container /usr/local/bin/start-container
|
||||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
COPY php.ini /etc/php/8.2/cli/conf.d/99-sail.ini
|
COPY php.ini /etc/php/8.2/cli/conf.d/99-sail.ini
|
||||||
|
|||||||
54
docker/8.2/nostr.json
Normal file
54
docker/8.2/nostr.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"relays": {
|
||||||
|
"wss://nostr.einundzwanzig.space": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://nostr.mom": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://nostr.fmt.wiz.biz": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://relay.damus.io": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://nostr-pub.wellorder.net": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://relay.nostr.info": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://offchain.pub": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://nos.lol": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://brb.io": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://relay.snort.social": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://relay.current.fyi": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"wss://nostr.relayer.se": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"following": null,
|
||||||
|
"privatekey": "NOSTR_PRIVATE_KEY"
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
@foreach($libraryItems as $libraryItem)
|
@foreach($libraryItems as $libraryItem)
|
||||||
@if($libraryItem->approved || $libraryItem->created_by === auth()->id() || auth()->user()?->hasRole('news-editor'))
|
@if($libraryItem->approved || $libraryItem->created_by === auth()->id() || auth()->user()?->hasRole('news-editor'))
|
||||||
<div wire:key="library_item_{{ $libraryItem->id }}"
|
<div wire:key="library_item_{{ $libraryItem->id }}" wire:loading.class="opacity-25"
|
||||||
class="flex flex-col overflow-hidden rounded-lg border-2 border-[#F7931A]">
|
class="flex flex-col overflow-hidden rounded-lg border-2 border-[#F7931A]">
|
||||||
<div class="flex-shrink-0 pt-6">
|
<div class="flex-shrink-0 pt-6">
|
||||||
<a href="{{ route('article.view', ['libraryItem' => $libraryItem]) }}">
|
<a href="{{ route('article.view', ['libraryItem' => $libraryItem]) }}">
|
||||||
@@ -84,24 +84,34 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
{{--<div>
|
<div>
|
||||||
@if($libraryItem->approved && auth()->user()?->hasRole('news-editor') && !$libraryItem->tweet)
|
@if($libraryItem->approved && auth()->user()?->hasRole('news-editor') && !$libraryItem->nostr)
|
||||||
<div x-data="{}">
|
<div x-data="{}">
|
||||||
<x-button xs
|
<x-button xs
|
||||||
|
purple
|
||||||
|
wire:loading.attr="disabled"
|
||||||
|
class="whitespace-nowrap"
|
||||||
x-on:click="$wireui.confirmDialog({
|
x-on:click="$wireui.confirmDialog({
|
||||||
icon: 'question',
|
icon: 'question',
|
||||||
title: '{{ __('Are you sure you want to tweet this article?')}}',
|
title: '{{ __('Are you sure you want to publish this article on Nostr?')}}',
|
||||||
accept: {label: '{{ __('Yes') }}',
|
accept: {label: '{{ __('Yes') }}',
|
||||||
execute: () => $wire.tweet({{ $libraryItem->id }})},
|
execute: () => $wire.nostr({{ $libraryItem->id }})},
|
||||||
reject: {label: '{{ __('No, cancel') }}'},
|
reject: {label: '{{ __('No, cancel') }}'},
|
||||||
})"
|
})"
|
||||||
>
|
>
|
||||||
<i class="fa fa-brand fa-twitter"></i>
|
<i class="fa fa-thin fa-message-plus"></i>
|
||||||
{{ __('Tweet') }}
|
{{ __('Publish on Nostr') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
</div>
|
</div>
|
||||||
|
@else
|
||||||
|
<div>
|
||||||
|
<x-badge purple>
|
||||||
|
<i class="fa fa-thin fa-check"></i>
|
||||||
|
{{ __('nostr') }}
|
||||||
|
</x-badge>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>--}}
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@if(!$libraryItem->approved && auth()->user()?->hasRole('news-editor'))
|
@if(!$libraryItem->approved && auth()->user()?->hasRole('news-editor'))
|
||||||
<x-button
|
<x-button
|
||||||
|
|||||||
Reference in New Issue
Block a user