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\Traits\TwitterTrait;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Livewire\Component;
|
||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
use WireUi\Traits\Actions;
|
||||
@@ -31,7 +32,7 @@ class ArticleOverview extends Component
|
||||
if ($libraryItem->lecturer->twitter_username && $libraryItem->type !== 'markdown_article') {
|
||||
$libraryItemName .= ' von @'.$libraryItem->lecturer->twitter_username;
|
||||
}
|
||||
if (! $libraryItem->lecturer->twitter_username) {
|
||||
if (!$libraryItem->lecturer->twitter_username) {
|
||||
$libraryItemName .= ' von '.$libraryItem->lecturer->name;
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ class ArticleOverview extends Component
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
if (! $libraryItem->approved) {
|
||||
if (!$libraryItem->approved) {
|
||||
$this->notification()
|
||||
->error(__('Article not approved yet'));
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
$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
|
||||
args:
|
||||
WWWGROUP: '${WWWGROUP}'
|
||||
NOSTR_PRIVATE_KEY: '${NOSTR_PRIVATE_KEY}'
|
||||
image: sail-8.2/app
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
@@ -41,7 +42,7 @@ services:
|
||||
networks:
|
||||
- sail
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
|
||||
test: [ "CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}" ]
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
redis:
|
||||
@@ -53,7 +54,7 @@ services:
|
||||
networks:
|
||||
- sail
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
test: [ "CMD", "redis-cli", "ping" ]
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
meilisearch:
|
||||
@@ -65,7 +66,7 @@ services:
|
||||
networks:
|
||||
- sail
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"]
|
||||
test: [ "CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health" ]
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
networks:
|
||||
|
||||
@@ -2,6 +2,7 @@ FROM ubuntu:22.04
|
||||
|
||||
LABEL maintainer="Taylor Otwell"
|
||||
|
||||
ARG NOSTR_PRIVATE_KEY
|
||||
ARG WWWGROUP
|
||||
ARG NODE_VERSION=18
|
||||
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 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 \
|
||||
&& 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 \
|
||||
@@ -48,6 +49,14 @@ RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2
|
||||
RUN groupadd --force -g $WWWGROUP 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 supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
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"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="bg-21gray flex flex-col h-screen justify-between">
|
||||
@push('feeds')
|
||||
<x-feed-links />
|
||||
<x-feed-links/>
|
||||
@endpush
|
||||
<livewire:frontend.header :country="null"/>
|
||||
<div class="relative bg-21gray px-6 pt-2 pb-20 lg:px-8 lg:pt-2 lg:pb-2">
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
@foreach($libraryItems as $libraryItem)
|
||||
@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]">
|
||||
<div class="flex-shrink-0 pt-6">
|
||||
<a href="{{ route('article.view', ['libraryItem' => $libraryItem]) }}">
|
||||
@@ -84,24 +84,34 @@
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
{{--<div>
|
||||
@if($libraryItem->approved && auth()->user()?->hasRole('news-editor') && !$libraryItem->tweet)
|
||||
<div>
|
||||
@if($libraryItem->approved && auth()->user()?->hasRole('news-editor') && !$libraryItem->nostr)
|
||||
<div x-data="{}">
|
||||
<x-button xs
|
||||
purple
|
||||
wire:loading.attr="disabled"
|
||||
class="whitespace-nowrap"
|
||||
x-on:click="$wireui.confirmDialog({
|
||||
icon: 'question',
|
||||
title: '{{ __('Are you sure you want to tweet this article?')}}',
|
||||
accept: {label: '{{ __('Yes') }}',
|
||||
execute: () => $wire.tweet({{ $libraryItem->id }})},
|
||||
reject: {label: '{{ __('No, cancel') }}'},
|
||||
})"
|
||||
icon: 'question',
|
||||
title: '{{ __('Are you sure you want to publish this article on Nostr?')}}',
|
||||
accept: {label: '{{ __('Yes') }}',
|
||||
execute: () => $wire.nostr({{ $libraryItem->id }})},
|
||||
reject: {label: '{{ __('No, cancel') }}'},
|
||||
})"
|
||||
>
|
||||
<i class="fa fa-brand fa-twitter"></i>
|
||||
{{ __('Tweet') }}
|
||||
<i class="fa fa-thin fa-message-plus"></i>
|
||||
{{ __('Publish on Nostr') }}
|
||||
</x-button>
|
||||
</div>
|
||||
@else
|
||||
<div>
|
||||
<x-badge purple>
|
||||
<i class="fa fa-thin fa-check"></i>
|
||||
{{ __('nostr') }}
|
||||
</x-badge>
|
||||
</div>
|
||||
@endif
|
||||
</div>--}}
|
||||
</div>
|
||||
<div>
|
||||
@if(!$libraryItem->approved && auth()->user()?->hasRole('news-editor'))
|
||||
<x-button
|
||||
|
||||
Reference in New Issue
Block a user