Compare commits
38 commits
feature/49
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e23dad5c5 | |||
| 16ce3b6324 | |||
| 03fa4b803f | |||
| b6290c0f8d | |||
| 4e0f0bb072 | |||
| 638983d42a | |||
| 0823cb796c | |||
|
|
f03a5c7603 | ||
| cd830dfbc1 | |||
| 3c3116ae55 | |||
| 366ff11904 | |||
| 0de5ea795d | |||
| 65cb836b51 | |||
| 7d4aa3da83 | |||
| 98fc361ab9 | |||
| da4fb6ac72 | |||
| be851be039 | |||
| f11d12dab3 | |||
| 5c00149e66 | |||
| 8c28f09921 | |||
| 1e70525f73 | |||
| 9d6e20b4f1 | |||
| 1b29c3fc13 | |||
| 65fefb9534 | |||
| c77667d263 | |||
| 3f41090174 | |||
| 8c335c9967 | |||
| 431f8a6d57 | |||
| 536dc3fcb8 | |||
| 997646be35 | |||
| 4af7b8a38c | |||
| d59128871e | |||
| 1c772e63cb | |||
| f2947b57c0 | |||
| cc4fd998ea | |||
| a4b5aee790 | |||
| 54abf52e20 | |||
| 84d402a91d |
376 changed files with 11984 additions and 22626 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -23,5 +23,6 @@ yarn-error.log
|
||||||
/.nova
|
/.nova
|
||||||
/.vscode
|
/.vscode
|
||||||
/.zed
|
/.zed
|
||||||
/backend/coverage-report*
|
/coverage-report*
|
||||||
|
/coverage.xml
|
||||||
/.claude
|
/.claude
|
||||||
|
|
|
||||||
127
Dockerfile
Normal file
127
Dockerfile
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
# Production Dockerfile with FrankenPHP
|
||||||
|
FROM dunglas/frankenphp:latest-php8.3-alpine
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
git \
|
||||||
|
mysql-client
|
||||||
|
|
||||||
|
# Install PHP extensions
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
opcache \
|
||||||
|
zip \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
bcmath \
|
||||||
|
redis \
|
||||||
|
pcntl
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Set fixed production environment variables
|
||||||
|
ENV APP_ENV=production \
|
||||||
|
APP_DEBUG=false \
|
||||||
|
DB_CONNECTION=mysql \
|
||||||
|
DB_HOST=db \
|
||||||
|
DB_PORT=3306 \
|
||||||
|
SESSION_DRIVER=redis \
|
||||||
|
CACHE_STORE=redis \
|
||||||
|
QUEUE_CONNECTION=redis \
|
||||||
|
LOG_CHANNEL=stack \
|
||||||
|
LOG_LEVEL=error
|
||||||
|
|
||||||
|
# Copy application code first
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Install PHP dependencies (production only)
|
||||||
|
RUN composer install --no-dev --no-interaction --optimize-autoloader
|
||||||
|
|
||||||
|
# Install ALL Node dependencies (including dev for building)
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Build frontend assets
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Remove node_modules after build to save space
|
||||||
|
RUN rm -rf node_modules
|
||||||
|
|
||||||
|
# Laravel optimizations
|
||||||
|
RUN php artisan config:cache \
|
||||||
|
&& php artisan route:cache \
|
||||||
|
&& php artisan view:cache \
|
||||||
|
&& composer dump-autoload --optimize
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chown -R www-data:www-data /app/storage /app/bootstrap/cache
|
||||||
|
|
||||||
|
# Configure Caddy
|
||||||
|
RUN cat > /etc/caddy/Caddyfile <<EOF
|
||||||
|
{
|
||||||
|
frankenphp
|
||||||
|
order php_server before file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
:8000 {
|
||||||
|
root * /app/public
|
||||||
|
|
||||||
|
php_server {
|
||||||
|
index index.php
|
||||||
|
}
|
||||||
|
|
||||||
|
encode gzip
|
||||||
|
|
||||||
|
file_server
|
||||||
|
|
||||||
|
header {
|
||||||
|
X-Frame-Options "SAMEORIGIN"
|
||||||
|
X-Content-Type-Options "nosniff"
|
||||||
|
X-XSS-Protection "1; mode=block"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:8000/up || exit 1
|
||||||
|
|
||||||
|
# Create startup script for production
|
||||||
|
RUN cat > /start-prod.sh <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Wait for database to be ready
|
||||||
|
echo "Waiting for database..."
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if mysqladmin ping -h "$DB_HOST" -u "$DB_USERNAME" -p"$DB_PASSWORD" --silent 2>/dev/null; then
|
||||||
|
echo "Database is ready!"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for database... ($i/30)"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run migrations
|
||||||
|
echo "Running migrations..."
|
||||||
|
php artisan migrate --force || echo "Migrations failed or already up-to-date"
|
||||||
|
|
||||||
|
# Start Horizon in the background
|
||||||
|
php artisan horizon &
|
||||||
|
|
||||||
|
# Start FrankenPHP
|
||||||
|
exec frankenphp run --config /etc/caddy/Caddyfile
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /start-prod.sh
|
||||||
|
|
||||||
|
# Start with our script
|
||||||
|
CMD ["/start-prod.sh"]
|
||||||
127
Dockerfile.dev
Normal file
127
Dockerfile.dev
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
# Development Dockerfile with FrankenPHP
|
||||||
|
FROM dunglas/frankenphp:latest-php8.3-alpine
|
||||||
|
|
||||||
|
# Install system dependencies + development tools
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
git \
|
||||||
|
mysql-client \
|
||||||
|
vim \
|
||||||
|
bash \
|
||||||
|
nano
|
||||||
|
|
||||||
|
# Install PHP extensions including xdebug for development
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
opcache \
|
||||||
|
zip \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
bcmath \
|
||||||
|
redis \
|
||||||
|
pcntl \
|
||||||
|
xdebug
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Configure PHP for development
|
||||||
|
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
||||||
|
|
||||||
|
# Configure Xdebug (disabled by default to reduce noise)
|
||||||
|
RUN echo "xdebug.mode=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo ";xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo ";xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo ";xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||||
|
|
||||||
|
# Configure Caddy for development (simpler, no worker mode)
|
||||||
|
RUN cat > /etc/caddy/Caddyfile <<EOF
|
||||||
|
{
|
||||||
|
frankenphp
|
||||||
|
order php_server before file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
:8000 {
|
||||||
|
root * /app/public
|
||||||
|
|
||||||
|
php_server {
|
||||||
|
index index.php
|
||||||
|
}
|
||||||
|
|
||||||
|
encode gzip
|
||||||
|
|
||||||
|
file_server
|
||||||
|
|
||||||
|
# Less strict headers for development
|
||||||
|
header {
|
||||||
|
X-Frame-Options "SAMEORIGIN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Install Node development dependencies globally
|
||||||
|
RUN npm install -g nodemon
|
||||||
|
|
||||||
|
# Create startup script for development
|
||||||
|
RUN cat > /start.sh <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create .env file if it doesn't exist
|
||||||
|
if [ ! -f ".env" ]; then
|
||||||
|
echo "Creating .env file from .env.example..."
|
||||||
|
cp .env.example .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install dependencies if volumes are empty
|
||||||
|
if [ ! -f "vendor/autoload.php" ]; then
|
||||||
|
echo "Installing composer dependencies..."
|
||||||
|
composer install
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Always reinstall node_modules in container to get correct native binaries for Alpine/musl
|
||||||
|
echo "Installing npm dependencies..."
|
||||||
|
rm -rf node_modules 2>/dev/null || true
|
||||||
|
rm -rf /app/.npm 2>/dev/null || true
|
||||||
|
npm install --cache /tmp/.npm
|
||||||
|
|
||||||
|
# Clear Laravel caches
|
||||||
|
php artisan config:clear || true
|
||||||
|
php artisan cache:clear || true
|
||||||
|
|
||||||
|
# Wait for database and run migrations
|
||||||
|
echo "Waiting for database..."
|
||||||
|
sleep 5
|
||||||
|
php artisan migrate --force || echo "Migration failed or not needed"
|
||||||
|
|
||||||
|
# Run seeders
|
||||||
|
echo "Running seeders..."
|
||||||
|
php artisan db:seed --force || echo "Seeding skipped or already done"
|
||||||
|
|
||||||
|
# Generate app key if not set
|
||||||
|
if [ -z "$APP_KEY" ] || [ "$APP_KEY" = "base64:YOUR_KEY_HERE" ]; then
|
||||||
|
echo "Generating application key..."
|
||||||
|
php artisan key:generate
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Vite dev server in background
|
||||||
|
npm run dev &
|
||||||
|
|
||||||
|
# Start Horizon (queue worker) in background
|
||||||
|
php artisan horizon &
|
||||||
|
|
||||||
|
# Start FrankenPHP
|
||||||
|
exec frankenphp run --config /etc/caddy/Caddyfile
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
# Expose ports
|
||||||
|
EXPOSE 8000 5173
|
||||||
|
|
||||||
|
# Use the startup script
|
||||||
|
CMD ["/start.sh"]
|
||||||
251
README.md
251
README.md
|
|
@ -1,205 +1,128 @@
|
||||||
# Fedi Feed Router
|
# FFR (Feed to Fediverse Router)
|
||||||
|
|
||||||
<div align="center">
|
A Laravel-based application for routing RSS/Atom feeds to Fediverse platforms like Lemmy. Built with Laravel, Livewire, and FrankenPHP for a modern, single-container deployment.
|
||||||
<img src="backend/public/images/ffr-logo-600.png" alt="FFR Logo" width="200">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`ffr` is a self-hosted tool for routing content from RSS/Atom feeds to the fediverse.
|
|
||||||
|
|
||||||
It watches feeds, matches entries based on keywords or rules, and publishes them to platforms like Lemmy, Mastodon, or anything ActivityPub-compatible.
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Keyword-based routing from any RSS/Atom feed
|
- **Feed aggregation** - Fetch articles from multiple RSS/Atom feeds
|
||||||
- Publish to Lemmy, Mastodon, or other fediverse services
|
- **Fediverse publishing** - Automatically post to Lemmy communities
|
||||||
- YAML or JSON route configs
|
- **Route configuration** - Map feeds to specific channels with keywords
|
||||||
- CLI and/or daemon mode
|
- **Approval workflow** - Optional manual approval before publishing
|
||||||
- Self-hosted, privacy-first, no SaaS dependencies
|
- **Queue processing** - Background job handling with Laravel Horizon
|
||||||
|
- **Single container deployment** - Simplified hosting with FrankenPHP
|
||||||
|
|
||||||
|
## Self-hosting
|
||||||
|
|
||||||
## Docker Deployment
|
The production image is available at `codeberg.org/lvl0/ffr:latest`.
|
||||||
|
|
||||||
### Building the Image
|
### docker-compose.yml
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build -t your-registry/lemmy-poster:latest .
|
|
||||||
docker push your-registry/lemmy-poster:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Docker Compose
|
|
||||||
|
|
||||||
Create a `docker-compose.yml` file:
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
app-web:
|
app:
|
||||||
image: your-registry/lemmy-poster:latest
|
image: codeberg.org/lvl0/ffr:latest
|
||||||
command: ["web"]
|
container_name: ffr_app
|
||||||
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
- DB_DATABASE=${DB_DATABASE}
|
APP_KEY: "${APP_KEY}"
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
APP_URL: "${APP_URL}"
|
||||||
- DB_PASSWORD=${DB_PASSWORD}
|
DB_DATABASE: "${DB_DATABASE}"
|
||||||
- LEMMY_INSTANCE=${LEMMY_INSTANCE}
|
DB_USERNAME: "${DB_USERNAME}"
|
||||||
- LEMMY_USERNAME=${LEMMY_USERNAME}
|
DB_PASSWORD: "${DB_PASSWORD}"
|
||||||
- LEMMY_PASSWORD=${LEMMY_PASSWORD}
|
REDIS_HOST: redis
|
||||||
- LEMMY_COMMUNITY=${LEMMY_COMMUNITY}
|
REDIS_PORT: 6379
|
||||||
|
volumes:
|
||||||
|
- app_storage:/app/storage
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- db
|
||||||
volumes:
|
- redis
|
||||||
- storage_data:/var/www/html/storage/app
|
healthcheck:
|
||||||
restart: unless-stopped
|
test: ["CMD", "curl", "-f", "http://localhost:8000/up"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
app-queue:
|
db:
|
||||||
image: your-registry/lemmy-poster:latest
|
image: mariadb:11
|
||||||
command: ["queue"]
|
container_name: ffr_db
|
||||||
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- DB_DATABASE=${DB_DATABASE}
|
MYSQL_DATABASE: "${DB_DATABASE}"
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
MYSQL_USER: "${DB_USERNAME}"
|
||||||
- DB_PASSWORD=${DB_PASSWORD}
|
MYSQL_PASSWORD: "${DB_PASSWORD}"
|
||||||
- LEMMY_INSTANCE=${LEMMY_INSTANCE}
|
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
|
||||||
- LEMMY_USERNAME=${LEMMY_USERNAME}
|
|
||||||
- LEMMY_PASSWORD=${LEMMY_PASSWORD}
|
|
||||||
- LEMMY_COMMUNITY=${LEMMY_COMMUNITY}
|
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
volumes:
|
volumes:
|
||||||
- storage_data:/var/www/html/storage/app
|
- db_data:/var/lib/mysql
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
mysql:
|
redis:
|
||||||
image: mysql:8.0
|
image: redis:7-alpine
|
||||||
command: --host-cache-size=0 --innodb-use-native-aio=0 --sql-mode=STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION --log-error-verbosity=1
|
container_name: ffr_redis
|
||||||
environment:
|
restart: always
|
||||||
- MYSQL_DATABASE=${DB_DATABASE}
|
|
||||||
- MYSQL_USER=${DB_USERNAME}
|
|
||||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
|
||||||
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
|
|
||||||
- TZ=UTC
|
|
||||||
volumes:
|
volumes:
|
||||||
- mysql_data:/var/lib/mysql
|
- redis_data:/data
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql_data:
|
db_data:
|
||||||
storage_data:
|
redis_data:
|
||||||
|
app_storage:
|
||||||
```
|
```
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
Create a `.env` file with:
|
| Variable | Required | Description |
|
||||||
|
|----------|----------|-------------|
|
||||||
|
| `APP_KEY` | Yes | Encryption key. Generate with: `echo "base64:$(openssl rand -base64 32)"` |
|
||||||
|
| `APP_URL` | Yes | Your domain (e.g., `https://ffr.example.com`) |
|
||||||
|
| `DB_DATABASE` | Yes | Database name |
|
||||||
|
| `DB_USERNAME` | Yes | Database user |
|
||||||
|
| `DB_PASSWORD` | Yes | Database password |
|
||||||
|
| `DB_ROOT_PASSWORD` | Yes | MariaDB root password |
|
||||||
|
|
||||||
```env
|
## Development
|
||||||
# Database Settings
|
|
||||||
DB_DATABASE=lemmy_poster
|
|
||||||
DB_USERNAME=lemmy_user
|
|
||||||
DB_PASSWORD=your-password
|
|
||||||
|
|
||||||
# Lemmy Settings
|
### NixOS / Nix
|
||||||
LEMMY_INSTANCE=your-lemmy-instance.com
|
|
||||||
LEMMY_USERNAME=your-lemmy-username
|
|
||||||
LEMMY_PASSWORD=your-lemmy-password
|
|
||||||
LEMMY_COMMUNITY=your-target-community
|
|
||||||
```
|
|
||||||
|
|
||||||
### Deployment
|
|
||||||
|
|
||||||
1. Build and push the image to your registry
|
|
||||||
2. Copy the docker-compose.yml to your server
|
|
||||||
3. Create the .env file with your environment variables
|
|
||||||
4. Run: `docker compose up -d`
|
|
||||||
|
|
||||||
The application will automatically:
|
|
||||||
- Wait for the database to be ready
|
|
||||||
- Run database migrations on first startup
|
|
||||||
- Start the queue worker after migrations complete
|
|
||||||
- Handle race conditions between web and queue containers
|
|
||||||
|
|
||||||
### Initial Setup
|
|
||||||
|
|
||||||
After deployment, the article refresh will run every hour. To trigger the initial article fetch manually:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose exec app-web php artisan article:refresh
|
git clone https://codeberg.org/lvl0/ffr.git
|
||||||
|
cd ffr
|
||||||
|
nix-shell
|
||||||
```
|
```
|
||||||
|
|
||||||
The application will then automatically:
|
The shell will display available commands and optionally start the containers for you.
|
||||||
- Fetch new articles every hour
|
|
||||||
- Publish valid articles every 5 minutes
|
|
||||||
- Sync community posts every 10 minutes
|
|
||||||
|
|
||||||
The web interface will be available on port 8000.
|
#### Available Commands
|
||||||
|
|
||||||
### Architecture
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `dev-up` | Start development environment |
|
||||||
|
| `dev-down` | Stop development environment |
|
||||||
|
| `dev-restart` | Restart containers |
|
||||||
|
| `dev-logs` | Follow app logs |
|
||||||
|
| `dev-logs-db` | Follow database logs |
|
||||||
|
| `dev-shell` | Enter app container |
|
||||||
|
| `dev-artisan <cmd>` | Run artisan commands |
|
||||||
|
| `prod-build [tag]` | Build and push prod image (default: latest) |
|
||||||
|
|
||||||
The application uses a multi-container setup:
|
#### Services
|
||||||
- **app-web**: Serves the Laravel web interface and handles HTTP requests
|
|
||||||
- **app-queue**: Processes background jobs (article fetching, Lemmy posting)
|
|
||||||
- **mysql**: Database storage for articles, logs, and application data
|
|
||||||
|
|
||||||
Both app containers use the same Docker image but with different commands (`web` or `queue`). Environment variables are passed from your `.env` file to configure database access and Lemmy integration.
|
| Service | URL |
|
||||||
|
|---------|-----|
|
||||||
|
| App | http://localhost:8000 |
|
||||||
|
| Vite | http://localhost:5173 |
|
||||||
|
| MariaDB | localhost:3307 |
|
||||||
|
| Redis | localhost:6380 |
|
||||||
|
|
||||||
## Development Setup
|
### Other Platforms
|
||||||
|
|
||||||
For local development with Podman:
|
Contributions welcome for development setup instructions on other platforms.
|
||||||
|
|
||||||
### Prerequisites
|
## License
|
||||||
|
|
||||||
- Podman and podman-compose installed
|
This project is open-source software licensed under the [AGPL-3.0 license](LICENSE).
|
||||||
- Git
|
|
||||||
|
|
||||||
### Quick Start
|
## Support
|
||||||
|
|
||||||
1. **Clone and start the development environment:**
|
For issues and questions, please use [Codeberg Issues](https://codeberg.org/lvl0/ffr/issues).
|
||||||
```bash
|
|
||||||
git clone <repository-url>
|
|
||||||
cd ffr
|
|
||||||
./docker/dev/podman/start-dev.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Access the application:**
|
|
||||||
- **Web interface**: http://localhost:8000
|
|
||||||
- **Vite dev server**: http://localhost:5173
|
|
||||||
- **Database**: localhost:3307
|
|
||||||
- **Redis**: localhost:6380
|
|
||||||
|
|
||||||
### Development Commands
|
|
||||||
|
|
||||||
**Load Sail-compatible aliases:**
|
|
||||||
```bash
|
|
||||||
source docker/dev/podman/podman-sail-alias.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
**Useful commands:**
|
|
||||||
```bash
|
|
||||||
# Run tests
|
|
||||||
ffr-test
|
|
||||||
|
|
||||||
# Execute artisan commands
|
|
||||||
ffr-artisan migrate
|
|
||||||
ffr-artisan tinker
|
|
||||||
|
|
||||||
# View application logs
|
|
||||||
ffr-logs
|
|
||||||
|
|
||||||
# Open container shell
|
|
||||||
ffr-shell
|
|
||||||
|
|
||||||
# Stop environment
|
|
||||||
podman-compose -f docker/dev/podman/docker-compose.yml down
|
|
||||||
```
|
|
||||||
|
|
||||||
Run tests:
|
|
||||||
```sh
|
|
||||||
podman-compose -f docker/dev/podman/docker-compose.yml exec app bash -c "cd backend && XDEBUG_MODE=coverage php artisan test --coverage-html=coverage-report"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Development Features
|
|
||||||
|
|
||||||
- **Hot reload**: Vite automatically reloads frontend changes
|
|
||||||
- **Database**: Pre-configured MySQL with migrations and seeders
|
|
||||||
- **Redis**: Configured for caching, sessions, and queues
|
|
||||||
- **Laravel Horizon**: Available for queue monitoring
|
|
||||||
- **No configuration needed**: Development environment uses preset configuration
|
|
||||||
|
|
|
||||||
13
app/Facades/LogSaver.php
Normal file
13
app/Facades/LogSaver.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class LogSaver extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return \App\Services\Log\LogSaver::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Jobs\ArticleDiscoveryJob;
|
use App\Jobs\ArticleDiscoveryJob;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
@ -47,12 +48,12 @@ public function approve(Article $article): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$article->approve('manual');
|
$article->approve('manual');
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
|
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
|
||||||
'Article approved and queued for publishing.'
|
'Article approved and queued for publishing.'
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->sendError('Failed to approve article: ' . $e->getMessage(), [], 500);
|
return $this->sendError('Failed to approve article: ' . $e->getMessage(), [], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,12 +65,12 @@ public function reject(Article $article): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$article->reject('manual');
|
$article->reject('manual');
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
|
new ArticleResource($article->fresh(['feed', 'articlePublication'])),
|
||||||
'Article rejected.'
|
'Article rejected.'
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->sendError('Failed to reject article: ' . $e->getMessage(), [], 500);
|
return $this->sendError('Failed to reject article: ' . $e->getMessage(), [], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,15 +81,14 @@ public function reject(Article $article): JsonResponse
|
||||||
public function refresh(): JsonResponse
|
public function refresh(): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Dispatch the article discovery job
|
|
||||||
ArticleDiscoveryJob::dispatch();
|
ArticleDiscoveryJob::dispatch();
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
null,
|
null,
|
||||||
'Article refresh started. New articles will appear shortly.'
|
'Article refresh started. New articles will appear shortly.'
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->sendError('Failed to start article refresh: ' . $e->getMessage(), [], 500);
|
return $this->sendError('Failed to start article refresh: ' . $e->getMessage(), [], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -57,9 +57,6 @@ public function store(StoreFeedRequest $request): JsonResponse
|
||||||
$validated['url'] = $adapter->getHomepageUrl();
|
$validated['url'] = $adapter->getHomepageUrl();
|
||||||
$validated['type'] = 'website';
|
$validated['type'] = 'website';
|
||||||
|
|
||||||
// Remove provider from validated data as it's not a database column
|
|
||||||
unset($validated['provider']);
|
|
||||||
|
|
||||||
$feed = Feed::create($validated);
|
$feed = Feed::create($validated);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
143
app/Http/Controllers/Api/V1/KeywordsController.php
Normal file
143
app/Http/Controllers/Api/V1/KeywordsController.php
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
|
use App\Models\Feed;
|
||||||
|
use App\Models\Keyword;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class KeywordsController extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display keywords for a specific route
|
||||||
|
*/
|
||||||
|
public function index(Feed $feed, PlatformChannel $channel): JsonResponse
|
||||||
|
{
|
||||||
|
$keywords = Keyword::where('feed_id', $feed->id)
|
||||||
|
->where('platform_channel_id', $channel->id)
|
||||||
|
->orderBy('keyword')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $this->sendResponse(
|
||||||
|
$keywords->toArray(),
|
||||||
|
'Keywords retrieved successfully.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a new keyword for a route
|
||||||
|
*/
|
||||||
|
public function store(Request $request, Feed $feed, PlatformChannel $channel): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validated = $request->validate([
|
||||||
|
'keyword' => 'required|string|max:255',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$validated['feed_id'] = $feed->id;
|
||||||
|
$validated['platform_channel_id'] = $channel->id;
|
||||||
|
$validated['is_active'] = $validated['is_active'] ?? true;
|
||||||
|
|
||||||
|
// Check if keyword already exists for this route
|
||||||
|
$existingKeyword = Keyword::where('feed_id', $feed->id)
|
||||||
|
->where('platform_channel_id', $channel->id)
|
||||||
|
->where('keyword', $validated['keyword'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existingKeyword) {
|
||||||
|
return $this->sendError('Keyword already exists for this route.', [], 409);
|
||||||
|
}
|
||||||
|
|
||||||
|
$keyword = Keyword::create($validated);
|
||||||
|
|
||||||
|
return $this->sendResponse(
|
||||||
|
$keyword->toArray(),
|
||||||
|
'Keyword created successfully!',
|
||||||
|
201
|
||||||
|
);
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
return $this->sendValidationError($e->errors());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->sendError('Failed to create keyword: ' . $e->getMessage(), [], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a keyword's status
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Feed $feed, PlatformChannel $channel, Keyword $keyword): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Verify the keyword belongs to this route
|
||||||
|
if ($keyword->feed_id !== $feed->id || $keyword->platform_channel_id !== $channel->id) {
|
||||||
|
return $this->sendNotFound('Keyword not found for this route.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$keyword->update($validated);
|
||||||
|
|
||||||
|
return $this->sendResponse(
|
||||||
|
$keyword->fresh()->toArray(),
|
||||||
|
'Keyword updated successfully!'
|
||||||
|
);
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
return $this->sendValidationError($e->errors());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->sendError('Failed to update keyword: ' . $e->getMessage(), [], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a keyword from a route
|
||||||
|
*/
|
||||||
|
public function destroy(Feed $feed, PlatformChannel $channel, Keyword $keyword): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Verify the keyword belongs to this route
|
||||||
|
if ($keyword->feed_id !== $feed->id || $keyword->platform_channel_id !== $channel->id) {
|
||||||
|
return $this->sendNotFound('Keyword not found for this route.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$keyword->delete();
|
||||||
|
|
||||||
|
return $this->sendResponse(
|
||||||
|
null,
|
||||||
|
'Keyword deleted successfully!'
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->sendError('Failed to delete keyword: ' . $e->getMessage(), [], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle keyword active status
|
||||||
|
*/
|
||||||
|
public function toggle(Feed $feed, PlatformChannel $channel, Keyword $keyword): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Verify the keyword belongs to this route
|
||||||
|
if ($keyword->feed_id !== $feed->id || $keyword->platform_channel_id !== $channel->id) {
|
||||||
|
return $this->sendNotFound('Keyword not found for this route.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$newStatus = !$keyword->is_active;
|
||||||
|
$keyword->update(['is_active' => $newStatus]);
|
||||||
|
|
||||||
|
$status = $newStatus ? 'activated' : 'deactivated';
|
||||||
|
|
||||||
|
return $this->sendResponse(
|
||||||
|
$keyword->fresh()->toArray(),
|
||||||
|
"Keyword {$status} successfully!"
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->sendError('Failed to toggle keyword status: ' . $e->getMessage(), [], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
use App\Http\Resources\PlatformAccountResource;
|
use App\Http\Resources\PlatformAccountResource;
|
||||||
use App\Http\Resources\PlatformChannelResource;
|
use App\Http\Resources\PlatformChannelResource;
|
||||||
use App\Http\Resources\RouteResource;
|
use App\Http\Resources\RouteResource;
|
||||||
|
use App\Jobs\ArticleDiscoveryJob;
|
||||||
use App\Models\Feed;
|
use App\Models\Feed;
|
||||||
use App\Models\Language;
|
use App\Models\Language;
|
||||||
use App\Models\PlatformAccount;
|
use App\Models\PlatformAccount;
|
||||||
|
|
@ -36,11 +37,15 @@ public function status(): JsonResponse
|
||||||
$hasChannel = PlatformChannel::where('is_active', true)->exists();
|
$hasChannel = PlatformChannel::where('is_active', true)->exists();
|
||||||
$hasRoute = Route::where('is_active', true)->exists();
|
$hasRoute = Route::where('is_active', true)->exists();
|
||||||
|
|
||||||
// Check if onboarding was explicitly skipped
|
// Check if onboarding was explicitly skipped or completed
|
||||||
$onboardingSkipped = Setting::where('key', 'onboarding_skipped')->value('value') === 'true';
|
$onboardingSkipped = Setting::where('key', 'onboarding_skipped')->value('value') === 'true';
|
||||||
|
$onboardingCompleted = Setting::where('key', 'onboarding_completed')->exists();
|
||||||
|
|
||||||
// User needs onboarding if they don't have the required components AND haven't skipped it
|
// User needs onboarding if:
|
||||||
$needsOnboarding = (!$hasPlatformAccount || !$hasFeed || !$hasChannel || !$hasRoute) && !$onboardingSkipped;
|
// 1. They haven't completed or skipped onboarding AND
|
||||||
|
// 2. They don't have all required components
|
||||||
|
$hasAllComponents = $hasPlatformAccount && $hasFeed && $hasChannel && $hasRoute;
|
||||||
|
$needsOnboarding = !$onboardingCompleted && !$onboardingSkipped && !$hasAllComponents;
|
||||||
|
|
||||||
// Determine current step
|
// Determine current step
|
||||||
$currentStep = null;
|
$currentStep = null;
|
||||||
|
|
@ -64,6 +69,8 @@ public function status(): JsonResponse
|
||||||
'has_channel' => $hasChannel,
|
'has_channel' => $hasChannel,
|
||||||
'has_route' => $hasRoute,
|
'has_route' => $hasRoute,
|
||||||
'onboarding_skipped' => $onboardingSkipped,
|
'onboarding_skipped' => $onboardingSkipped,
|
||||||
|
'onboarding_completed' => $onboardingCompleted,
|
||||||
|
'missing_components' => !$hasAllComponents && $onboardingCompleted,
|
||||||
], 'Onboarding status retrieved successfully.');
|
], 'Onboarding status retrieved successfully.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,11 +97,17 @@ public function options(): JsonResponse
|
||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get(['id', 'platform_instance_id', 'name', 'display_name', 'description']);
|
->get(['id', 'platform_instance_id', 'name', 'display_name', 'description']);
|
||||||
|
|
||||||
|
// Get feed providers from config
|
||||||
|
$feedProviders = collect(config('feed.providers', []))
|
||||||
|
->filter(fn($provider) => $provider['is_active'])
|
||||||
|
->values();
|
||||||
|
|
||||||
return $this->sendResponse([
|
return $this->sendResponse([
|
||||||
'languages' => $languages,
|
'languages' => $languages,
|
||||||
'platform_instances' => $platformInstances,
|
'platform_instances' => $platformInstances,
|
||||||
'feeds' => $feeds,
|
'feeds' => $feeds,
|
||||||
'platform_channels' => $platformChannels,
|
'platform_channels' => $platformChannels,
|
||||||
|
'feed_providers' => $feedProviders,
|
||||||
], 'Onboarding options retrieved successfully.');
|
], 'Onboarding options retrieved successfully.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,14 +224,17 @@ public function createFeed(Request $request): JsonResponse
|
||||||
$url = 'https://www.belganewsagency.eu/';
|
$url = 'https://www.belganewsagency.eu/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$feed = Feed::create([
|
$feed = Feed::firstOrCreate(
|
||||||
'name' => $validated['name'],
|
['url' => $url],
|
||||||
'url' => $url,
|
[
|
||||||
'type' => $type,
|
'name' => $validated['name'],
|
||||||
'language_id' => $validated['language_id'],
|
'type' => $type,
|
||||||
'description' => $validated['description'] ?? null,
|
'provider' => $provider,
|
||||||
'is_active' => true,
|
'language_id' => $validated['language_id'],
|
||||||
]);
|
'description' => $validated['description'] ?? null,
|
||||||
|
'is_active' => true,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new FeedResource($feed->load('language')),
|
new FeedResource($feed->load('language')),
|
||||||
|
|
@ -228,6 +244,7 @@ public function createFeed(Request $request): JsonResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create channel for onboarding
|
* Create channel for onboarding
|
||||||
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function createChannel(Request $request): JsonResponse
|
public function createChannel(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
@ -244,6 +261,22 @@ public function createChannel(Request $request): JsonResponse
|
||||||
|
|
||||||
$validated = $validator->validated();
|
$validated = $validator->validated();
|
||||||
|
|
||||||
|
// Get the platform instance to check for active accounts
|
||||||
|
$platformInstance = PlatformInstance::findOrFail($validated['platform_instance_id']);
|
||||||
|
|
||||||
|
// Check if there are active platform accounts for this instance
|
||||||
|
$activeAccounts = PlatformAccount::where('instance_url', $platformInstance->url)
|
||||||
|
->where('is_active', true)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($activeAccounts->isEmpty()) {
|
||||||
|
return $this->sendError(
|
||||||
|
'Cannot create channel: No active platform accounts found for this instance. Please create a platform account first.',
|
||||||
|
[],
|
||||||
|
422
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$channel = PlatformChannel::create([
|
$channel = PlatformChannel::create([
|
||||||
'platform_instance_id' => $validated['platform_instance_id'],
|
'platform_instance_id' => $validated['platform_instance_id'],
|
||||||
'channel_id' => $validated['name'], // For Lemmy, this is the community name
|
'channel_id' => $validated['name'], // For Lemmy, this is the community name
|
||||||
|
|
@ -254,14 +287,25 @@ public function createChannel(Request $request): JsonResponse
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Automatically attach the first active account to the channel
|
||||||
|
$firstAccount = $activeAccounts->first();
|
||||||
|
$channel->platformAccounts()->attach($firstAccount->id, [
|
||||||
|
'is_active' => true,
|
||||||
|
'priority' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new PlatformChannelResource($channel->load(['platformInstance', 'language'])),
|
new PlatformChannelResource($channel->load(['platformInstance', 'language', 'platformAccounts'])),
|
||||||
'Channel created successfully.'
|
'Channel created successfully and linked to platform account.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create route for onboarding
|
* Create route for onboarding
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function createRoute(Request $request): JsonResponse
|
public function createRoute(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
@ -269,7 +313,6 @@ public function createRoute(Request $request): JsonResponse
|
||||||
'feed_id' => 'required|exists:feeds,id',
|
'feed_id' => 'required|exists:feeds,id',
|
||||||
'platform_channel_id' => 'required|exists:platform_channels,id',
|
'platform_channel_id' => 'required|exists:platform_channels,id',
|
||||||
'priority' => 'nullable|integer|min:1|max:100',
|
'priority' => 'nullable|integer|min:1|max:100',
|
||||||
'filters' => 'nullable|array',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
|
|
@ -282,10 +325,13 @@ public function createRoute(Request $request): JsonResponse
|
||||||
'feed_id' => $validated['feed_id'],
|
'feed_id' => $validated['feed_id'],
|
||||||
'platform_channel_id' => $validated['platform_channel_id'],
|
'platform_channel_id' => $validated['platform_channel_id'],
|
||||||
'priority' => $validated['priority'] ?? 50,
|
'priority' => $validated['priority'] ?? 50,
|
||||||
'filters' => $validated['filters'] ?? [],
|
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Trigger article discovery when the first route is created during onboarding
|
||||||
|
// This ensures articles start being fetched immediately after setup
|
||||||
|
ArticleDiscoveryJob::dispatch();
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new RouteResource($route->load(['feed', 'platformChannel'])),
|
new RouteResource($route->load(['feed', 'platformChannel'])),
|
||||||
'Route created successfully.'
|
'Route created successfully.'
|
||||||
|
|
@ -297,10 +343,11 @@ public function createRoute(Request $request): JsonResponse
|
||||||
*/
|
*/
|
||||||
public function complete(): JsonResponse
|
public function complete(): JsonResponse
|
||||||
{
|
{
|
||||||
// In a real implementation, you might want to update a user preference
|
// Track that onboarding has been completed with a timestamp
|
||||||
// or create a setting that tracks onboarding completion
|
Setting::updateOrCreate(
|
||||||
// For now, we'll just return success since the onboarding status
|
['key' => 'onboarding_completed'],
|
||||||
// is determined by the existence of platform accounts, feeds, and channels
|
['value' => now()->toIso8601String()]
|
||||||
|
);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
['completed' => true],
|
['completed' => true],
|
||||||
|
|
@ -330,10 +377,12 @@ public function skip(): JsonResponse
|
||||||
public function resetSkip(): JsonResponse
|
public function resetSkip(): JsonResponse
|
||||||
{
|
{
|
||||||
Setting::where('key', 'onboarding_skipped')->delete();
|
Setting::where('key', 'onboarding_skipped')->delete();
|
||||||
|
// Also reset completion status to allow re-onboarding
|
||||||
|
Setting::where('key', 'onboarding_completed')->delete();
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
['reset' => true],
|
['reset' => true],
|
||||||
'Onboarding skip status reset successfully.'
|
'Onboarding status reset successfully.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,11 +44,36 @@ public function store(Request $request): JsonResponse
|
||||||
|
|
||||||
$validated['is_active'] = $validated['is_active'] ?? true;
|
$validated['is_active'] = $validated['is_active'] ?? true;
|
||||||
|
|
||||||
|
// Get the platform instance to check for active accounts
|
||||||
|
$platformInstance = \App\Models\PlatformInstance::findOrFail($validated['platform_instance_id']);
|
||||||
|
|
||||||
|
// Check if there are active platform accounts for this instance
|
||||||
|
$activeAccounts = PlatformAccount::where('instance_url', $platformInstance->url)
|
||||||
|
->where('is_active', true)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($activeAccounts->isEmpty()) {
|
||||||
|
return $this->sendError(
|
||||||
|
'Cannot create channel: No active platform accounts found for this instance. Please create a platform account first.',
|
||||||
|
[],
|
||||||
|
422
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$channel = PlatformChannel::create($validated);
|
$channel = PlatformChannel::create($validated);
|
||||||
|
|
||||||
|
// Automatically attach the first active account to the channel
|
||||||
|
$firstAccount = $activeAccounts->first();
|
||||||
|
$channel->platformAccounts()->attach($firstAccount->id, [
|
||||||
|
'is_active' => true,
|
||||||
|
'priority' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new PlatformChannelResource($channel->load('platformInstance')),
|
new PlatformChannelResource($channel->load(['platformInstance', 'platformAccounts'])),
|
||||||
'Platform channel created successfully!',
|
'Platform channel created successfully and linked to platform account!',
|
||||||
201
|
201
|
||||||
);
|
);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
|
|
@ -17,7 +17,7 @@ class RoutingController extends BaseController
|
||||||
*/
|
*/
|
||||||
public function index(): JsonResponse
|
public function index(): JsonResponse
|
||||||
{
|
{
|
||||||
$routes = Route::with(['feed', 'platformChannel'])
|
$routes = Route::with(['feed', 'platformChannel', 'keywords'])
|
||||||
->orderBy('is_active', 'desc')
|
->orderBy('is_active', 'desc')
|
||||||
->orderBy('priority', 'asc')
|
->orderBy('priority', 'asc')
|
||||||
->get();
|
->get();
|
||||||
|
|
@ -47,7 +47,7 @@ public function store(Request $request): JsonResponse
|
||||||
$route = Route::create($validated);
|
$route = Route::create($validated);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new RouteResource($route->load(['feed', 'platformChannel'])),
|
new RouteResource($route->load(['feed', 'platformChannel', 'keywords'])),
|
||||||
'Routing configuration created successfully!',
|
'Routing configuration created successfully!',
|
||||||
201
|
201
|
||||||
);
|
);
|
||||||
|
|
@ -69,7 +69,7 @@ public function show(Feed $feed, PlatformChannel $channel): JsonResponse
|
||||||
return $this->sendNotFound('Routing configuration not found.');
|
return $this->sendNotFound('Routing configuration not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$route->load(['feed', 'platformChannel']);
|
$route->load(['feed', 'platformChannel', 'keywords']);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new RouteResource($route),
|
new RouteResource($route),
|
||||||
|
|
@ -99,7 +99,7 @@ public function update(Request $request, Feed $feed, PlatformChannel $channel):
|
||||||
->update($validated);
|
->update($validated);
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new RouteResource($route->fresh(['feed', 'platformChannel'])),
|
new RouteResource($route->fresh(['feed', 'platformChannel', 'keywords'])),
|
||||||
'Routing configuration updated successfully!'
|
'Routing configuration updated successfully!'
|
||||||
);
|
);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
|
|
@ -154,7 +154,7 @@ public function toggle(Feed $feed, PlatformChannel $channel): JsonResponse
|
||||||
$status = $newStatus ? 'activated' : 'deactivated';
|
$status = $newStatus ? 'activated' : 'deactivated';
|
||||||
|
|
||||||
return $this->sendResponse(
|
return $this->sendResponse(
|
||||||
new RouteResource($route->fresh(['feed', 'platformChannel'])),
|
new RouteResource($route->fresh(['feed', 'platformChannel', 'keywords'])),
|
||||||
"Routing configuration {$status} successfully!"
|
"Routing configuration {$status} successfully!"
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Auth\LoginRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AuthenticatedSessionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the login view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming authentication request.
|
||||||
|
*/
|
||||||
|
public function store(LoginRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->authenticate();
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy an authenticated session.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
Auth::guard('web')->logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ConfirmablePasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the confirm password view.
|
||||||
|
*/
|
||||||
|
public function show(): View
|
||||||
|
{
|
||||||
|
return view('auth.confirm-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm the user's password.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if (! Auth::guard('web')->validate([
|
||||||
|
'email' => $request->user()->email,
|
||||||
|
'password' => $request->password,
|
||||||
|
])) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'password' => __('auth.password'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->session()->put('auth.password_confirmed_at', time());
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class EmailVerificationNotificationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Send a new email verification notification.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->sendEmailVerificationNotification();
|
||||||
|
|
||||||
|
return back()->with('status', 'verification-link-sent');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class EmailVerificationPromptController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the email verification prompt.
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request): RedirectResponse|View
|
||||||
|
{
|
||||||
|
return $request->user()->hasVerifiedEmail()
|
||||||
|
? redirect()->intended(route('dashboard', absolute: false))
|
||||||
|
: view('auth.verify-email');
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
62
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class NewPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset view.
|
||||||
|
*/
|
||||||
|
public function create(Request $request): View
|
||||||
|
{
|
||||||
|
return view('auth.reset-password', ['request' => $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming new password request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token' => ['required'],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Here we will attempt to reset the user's password. If it is successful we
|
||||||
|
// will update the password on an actual user model and persist it to the
|
||||||
|
// database. Otherwise we will parse the error and return the response.
|
||||||
|
$status = Password::reset(
|
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||||
|
function (User $user) use ($request) {
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'remember_token' => Str::random(60),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
event(new PasswordReset($user));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the password was successfully reset, we will redirect the user back to
|
||||||
|
// the application's home authenticated view. If there is an error we can
|
||||||
|
// redirect them back to where they came from with their error message.
|
||||||
|
return $status == Password::PASSWORD_RESET
|
||||||
|
? redirect()->route('login')->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
|
class PasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Update the user's password.
|
||||||
|
*/
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validateWithBag('updatePassword', [
|
||||||
|
'current_password' => ['required', 'current_password'],
|
||||||
|
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->user()->update([
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('status', 'password-updated');
|
||||||
|
}
|
||||||
|
}
|
||||||
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class PasswordResetLinkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset link request view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.forgot-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming password reset link request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// We will send the password reset link to this user. Once we have attempted
|
||||||
|
// to send the link, we will examine the response then see the message we
|
||||||
|
// need to show to the user. Finally, we'll send out a proper response.
|
||||||
|
$status = Password::sendResetLink(
|
||||||
|
$request->only('email')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $status == Password::RESET_LINK_SENT
|
||||||
|
? back()->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class RegisteredUserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the registration view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming registration request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
event(new Registered($user));
|
||||||
|
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
return redirect(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Auth\Events\Verified;
|
||||||
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class VerifyEmailController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Mark the authenticated user's email address as verified.
|
||||||
|
*/
|
||||||
|
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->user()->markEmailAsVerified()) {
|
||||||
|
event(new Verified($request->user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
60
app/Http/Controllers/ProfileController.php
Normal file
60
app/Http/Controllers/ProfileController.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Requests\ProfileUpdateRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the user's profile form.
|
||||||
|
*/
|
||||||
|
public function edit(Request $request): View
|
||||||
|
{
|
||||||
|
return view('profile.edit', [
|
||||||
|
'user' => $request->user(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's profile information.
|
||||||
|
*/
|
||||||
|
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->user()->fill($request->validated());
|
||||||
|
|
||||||
|
if ($request->user()->isDirty('email')) {
|
||||||
|
$request->user()->email_verified_at = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->save();
|
||||||
|
|
||||||
|
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the user's account.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validateWithBag('userDeletion', [
|
||||||
|
'password' => ['required', 'current_password'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return Redirect::to('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Middleware/EnsureOnboardingComplete.php
Normal file
29
app/Http/Middleware/EnsureOnboardingComplete.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Services\OnboardingService;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class EnsureOnboardingComplete
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private OnboardingService $onboardingService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* Redirect to onboarding if the user hasn't completed setup.
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if ($this->onboardingService->needsOnboarding()) {
|
||||||
|
return redirect()->route('onboarding');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Middleware/RedirectIfOnboardingComplete.php
Normal file
29
app/Http/Middleware/RedirectIfOnboardingComplete.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Services\OnboardingService;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class RedirectIfOnboardingComplete
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private OnboardingService $onboardingService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* Redirect to dashboard if onboarding is already complete.
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (!$this->onboardingService->needsOnboarding()) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Lockout;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class LoginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => ['required', 'string', 'email'],
|
||||||
|
'password' => ['required', 'string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to authenticate the request's credentials.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function authenticate(): void
|
||||||
|
{
|
||||||
|
$this->ensureIsNotRateLimited();
|
||||||
|
|
||||||
|
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||||
|
RateLimiter::hit($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.failed'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::clear($this->throttleKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the login request is not rate limited.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function ensureIsNotRateLimited(): void
|
||||||
|
{
|
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event(new Lockout($this));
|
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.throttle', [
|
||||||
|
'seconds' => $seconds,
|
||||||
|
'minutes' => ceil($seconds / 60),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rate limiting throttle key for the request.
|
||||||
|
*/
|
||||||
|
public function throttleKey(): string
|
||||||
|
{
|
||||||
|
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ProfileUpdateRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'lowercase',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique(User::class)->ignore($this->user()->id),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,13 +5,11 @@
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
*/
|
||||||
class ArticleResource extends JsonResource
|
class ArticleResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
@ -27,10 +25,11 @@ public function toArray(Request $request): array
|
||||||
'approved_by' => $this->approved_by,
|
'approved_by' => $this->approved_by,
|
||||||
'fetched_at' => $this->fetched_at?->toISOString(),
|
'fetched_at' => $this->fetched_at?->toISOString(),
|
||||||
'validated_at' => $this->validated_at?->toISOString(),
|
'validated_at' => $this->validated_at?->toISOString(),
|
||||||
|
'is_published' => $this->relationLoaded('articlePublication') && $this->articlePublication !== null,
|
||||||
'created_at' => $this->created_at->toISOString(),
|
'created_at' => $this->created_at->toISOString(),
|
||||||
'updated_at' => $this->updated_at->toISOString(),
|
'updated_at' => $this->updated_at->toISOString(),
|
||||||
'feed' => new FeedResource($this->whenLoaded('feed')),
|
'feed' => new FeedResource($this->whenLoaded('feed')),
|
||||||
'article_publication' => new ArticlePublicationResource($this->whenLoaded('articlePublication')),
|
'article_publication' => new ArticlePublicationResource($this->whenLoaded('articlePublication')),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,6 +19,8 @@ public function toArray(Request $request): array
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'url' => $this->url,
|
'url' => $this->url,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
|
'provider' => $this->provider,
|
||||||
|
'language_id' => $this->language_id,
|
||||||
'is_active' => $this->is_active,
|
'is_active' => $this->is_active,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'created_at' => $this->created_at->toISOString(),
|
'created_at' => $this->created_at->toISOString(),
|
||||||
|
|
@ -21,6 +21,7 @@ public function toArray(Request $request): array
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'display_name' => $this->display_name,
|
'display_name' => $this->display_name,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
|
'language_id' => $this->language_id,
|
||||||
'is_active' => $this->is_active,
|
'is_active' => $this->is_active,
|
||||||
'created_at' => $this->created_at->toISOString(),
|
'created_at' => $this->created_at->toISOString(),
|
||||||
'updated_at' => $this->updated_at->toISOString(),
|
'updated_at' => $this->updated_at->toISOString(),
|
||||||
|
|
@ -24,6 +24,15 @@ public function toArray(Request $request): array
|
||||||
'updated_at' => $this->updated_at->toISOString(),
|
'updated_at' => $this->updated_at->toISOString(),
|
||||||
'feed' => new FeedResource($this->whenLoaded('feed')),
|
'feed' => new FeedResource($this->whenLoaded('feed')),
|
||||||
'platform_channel' => new PlatformChannelResource($this->whenLoaded('platformChannel')),
|
'platform_channel' => new PlatformChannelResource($this->whenLoaded('platformChannel')),
|
||||||
|
'keywords' => $this->whenLoaded('keywords', function () {
|
||||||
|
return $this->keywords->map(function ($keyword) {
|
||||||
|
return [
|
||||||
|
'id' => $keyword->id,
|
||||||
|
'keyword' => $keyword->keyword,
|
||||||
|
'is_active' => $keyword->is_active,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,17 +20,17 @@ public function __construct(
|
||||||
$this->onQueue('feed-discovery');
|
$this->onQueue('feed-discovery');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
||||||
{
|
{
|
||||||
LogSaver::info('Starting feed article fetch', null, [
|
$logSaver->info('Starting feed article fetch', null, [
|
||||||
'feed_id' => $this->feed->id,
|
'feed_id' => $this->feed->id,
|
||||||
'feed_name' => $this->feed->name,
|
'feed_name' => $this->feed->name,
|
||||||
'feed_url' => $this->feed->url
|
'feed_url' => $this->feed->url
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$articles = ArticleFetcher::getArticlesFromFeed($this->feed);
|
$articles = $articleFetcher->getArticlesFromFeed($this->feed);
|
||||||
|
|
||||||
LogSaver::info('Feed article fetch completed', null, [
|
$logSaver->info('Feed article fetch completed', null, [
|
||||||
'feed_id' => $this->feed->id,
|
'feed_id' => $this->feed->id,
|
||||||
'feed_name' => $this->feed->name,
|
'feed_name' => $this->feed->name,
|
||||||
'articles_count' => $articles->count()
|
'articles_count' => $articles->count()
|
||||||
|
|
@ -41,9 +41,11 @@ public function handle(): void
|
||||||
|
|
||||||
public static function dispatchForAllActiveFeeds(): void
|
public static function dispatchForAllActiveFeeds(): void
|
||||||
{
|
{
|
||||||
|
$logSaver = app(LogSaver::class);
|
||||||
|
|
||||||
Feed::where('is_active', true)
|
Feed::where('is_active', true)
|
||||||
->get()
|
->get()
|
||||||
->each(function (Feed $feed, $index) {
|
->each(function (Feed $feed, $index) use ($logSaver) {
|
||||||
// Space jobs apart to avoid overwhelming feeds
|
// Space jobs apart to avoid overwhelming feeds
|
||||||
$delayMinutes = $index * self::FEED_DISCOVERY_DELAY_MINUTES;
|
$delayMinutes = $index * self::FEED_DISCOVERY_DELAY_MINUTES;
|
||||||
|
|
||||||
|
|
@ -51,7 +53,7 @@ public static function dispatchForAllActiveFeeds(): void
|
||||||
->delay(now()->addMinutes($delayMinutes))
|
->delay(now()->addMinutes($delayMinutes))
|
||||||
->onQueue('feed-discovery');
|
->onQueue('feed-discovery');
|
||||||
|
|
||||||
LogSaver::info('Dispatched feed discovery job', null, [
|
$logSaver->info('Dispatched feed discovery job', null, [
|
||||||
'feed_id' => $feed->id,
|
'feed_id' => $feed->id,
|
||||||
'feed_name' => $feed->name,
|
'feed_name' => $feed->name,
|
||||||
'delay_minutes' => $delayMinutes
|
'delay_minutes' => $delayMinutes
|
||||||
|
|
@ -16,18 +16,18 @@ public function __construct()
|
||||||
$this->onQueue('feed-discovery');
|
$this->onQueue('feed-discovery');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(LogSaver $logSaver): void
|
||||||
{
|
{
|
||||||
if (!Setting::isArticleProcessingEnabled()) {
|
if (!Setting::isArticleProcessingEnabled()) {
|
||||||
LogSaver::info('Article processing is disabled. Article discovery skipped.');
|
$logSaver->info('Article processing is disabled. Article discovery skipped.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSaver::info('Starting article discovery for all active feeds');
|
$logSaver->info('Starting article discovery for all active feeds');
|
||||||
|
|
||||||
ArticleDiscoveryForFeedJob::dispatchForAllActiveFeeds();
|
ArticleDiscoveryForFeedJob::dispatchForAllActiveFeeds();
|
||||||
|
|
||||||
LogSaver::info('Article discovery jobs dispatched for all active feeds');
|
$logSaver->info('Article discovery jobs dispatched for all active feeds');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
69
app/Jobs/PublishNextArticleJob.php
Normal file
69
app/Jobs/PublishNextArticleJob.php
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Exceptions\PublishException;
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Services\Article\ArticleFetcher;
|
||||||
|
use App\Services\Publishing\ArticlePublishingService;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
|
||||||
|
class PublishNextArticleJob implements ShouldQueue, ShouldBeUnique
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of seconds after which the job's unique lock will be released.
|
||||||
|
*/
|
||||||
|
public int $uniqueFor = 300;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->onQueue('publishing');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
* @throws PublishException
|
||||||
|
*/
|
||||||
|
public function handle(ArticleFetcher $articleFetcher, ArticlePublishingService $publishingService): void
|
||||||
|
{
|
||||||
|
// Get the oldest approved article that hasn't been published yet
|
||||||
|
$article = Article::where('approval_status', 'approved')
|
||||||
|
->whereDoesntHave('articlePublication')
|
||||||
|
->oldest('created_at')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $article) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger()->info('Publishing next article from scheduled job', [
|
||||||
|
'article_id' => $article->id,
|
||||||
|
'title' => $article->title,
|
||||||
|
'url' => $article->url,
|
||||||
|
'created_at' => $article->created_at
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Fetch article data
|
||||||
|
$extractedData = $articleFetcher->fetchArticleData($article);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$publishingService->publishToRoutedChannels($article, $extractedData);
|
||||||
|
|
||||||
|
logger()->info('Successfully published article', [
|
||||||
|
'article_id' => $article->id,
|
||||||
|
'title' => $article->title
|
||||||
|
]);
|
||||||
|
} catch (PublishException $e) {
|
||||||
|
logger()->error('Failed to publish article', [
|
||||||
|
'article_id' => $article->id,
|
||||||
|
'error' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,32 +27,34 @@ public function __construct(
|
||||||
|
|
||||||
public static function dispatchForAllActiveChannels(): void
|
public static function dispatchForAllActiveChannels(): void
|
||||||
{
|
{
|
||||||
|
$logSaver = app(LogSaver::class);
|
||||||
|
|
||||||
PlatformChannel::with(['platformInstance', 'platformAccounts'])
|
PlatformChannel::with(['platformInstance', 'platformAccounts'])
|
||||||
->whereHas('platformInstance', fn ($query) => $query->where('platform', PlatformEnum::LEMMY))
|
->whereHas('platformInstance', fn ($query) => $query->where('platform', PlatformEnum::LEMMY))
|
||||||
->whereHas('platformAccounts', fn ($query) => $query->where('is_active', true))
|
->whereHas('platformAccounts', fn ($query) => $query->where('platform_accounts.is_active', true))
|
||||||
->where('is_active', true)
|
->where('platform_channels.is_active', true)
|
||||||
->get()
|
->get()
|
||||||
->each(function (PlatformChannel $channel) {
|
->each(function (PlatformChannel $channel) use ($logSaver) {
|
||||||
self::dispatch($channel);
|
self::dispatch($channel);
|
||||||
LogSaver::info('Dispatched sync job for channel', $channel);
|
$logSaver->info('Dispatched sync job for channel', $channel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(LogSaver $logSaver): void
|
||||||
{
|
{
|
||||||
LogSaver::info('Starting channel posts sync job', $this->channel);
|
$logSaver->info('Starting channel posts sync job', $this->channel);
|
||||||
|
|
||||||
match ($this->channel->platformInstance->platform) {
|
match ($this->channel->platformInstance->platform) {
|
||||||
PlatformEnum::LEMMY => $this->syncLemmyChannelPosts(),
|
PlatformEnum::LEMMY => $this->syncLemmyChannelPosts($logSaver),
|
||||||
};
|
};
|
||||||
|
|
||||||
LogSaver::info('Channel posts sync job completed', $this->channel);
|
$logSaver->info('Channel posts sync job completed', $this->channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws PlatformAuthException
|
* @throws PlatformAuthException
|
||||||
*/
|
*/
|
||||||
private function syncLemmyChannelPosts(): void
|
private function syncLemmyChannelPosts(LogSaver $logSaver): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/** @var Collection<int, PlatformAccount> $accounts */
|
/** @var Collection<int, PlatformAccount> $accounts */
|
||||||
|
|
@ -72,10 +74,10 @@ private function syncLemmyChannelPosts(): void
|
||||||
|
|
||||||
$api->syncChannelPosts($token, $platformChannelId, $this->channel->name);
|
$api->syncChannelPosts($token, $platformChannelId, $this->channel->name);
|
||||||
|
|
||||||
LogSaver::info('Channel posts synced successfully', $this->channel);
|
$logSaver->info('Channel posts synced successfully', $this->channel);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
LogSaver::error('Failed to sync channel posts', $this->channel, [
|
$logSaver->error('Failed to sync channel posts', $this->channel, [
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
38
app/Listeners/LogExceptionToDatabase.php
Normal file
38
app/Listeners/LogExceptionToDatabase.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\ExceptionLogged;
|
||||||
|
use App\Events\ExceptionOccurred;
|
||||||
|
use App\Models\Log;
|
||||||
|
class LogExceptionToDatabase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle(ExceptionOccurred $event): void
|
||||||
|
{
|
||||||
|
// Truncate the message to prevent database errors
|
||||||
|
$message = strlen($event->message) > 255
|
||||||
|
? substr($event->message, 0, 252) . '...'
|
||||||
|
: $event->message;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$log = Log::create([
|
||||||
|
'level' => $event->level,
|
||||||
|
'message' => $message,
|
||||||
|
'context' => [
|
||||||
|
'exception_class' => get_class($event->exception),
|
||||||
|
'file' => $event->exception->getFile(),
|
||||||
|
'line' => $event->exception->getLine(),
|
||||||
|
'trace' => $event->exception->getTraceAsString(),
|
||||||
|
...$event->context
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
ExceptionLogged::dispatch($log);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Prevent infinite recursion by not logging this exception
|
||||||
|
// Optionally log to file or other non-database destination
|
||||||
|
error_log("Failed to log exception to database: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\NewArticleFetched;
|
use App\Events\NewArticleFetched;
|
||||||
use App\Events\ArticleReadyToPublish;
|
use App\Events\ArticleApproved;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Services\Article\ValidationService;
|
use App\Services\Article\ValidationService;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
@ -12,7 +12,7 @@ class ValidateArticleListener implements ShouldQueue
|
||||||
{
|
{
|
||||||
public string $queue = 'default';
|
public string $queue = 'default';
|
||||||
|
|
||||||
public function handle(NewArticleFetched $event): void
|
public function handle(NewArticleFetched $event, ValidationService $validationService): void
|
||||||
{
|
{
|
||||||
$article = $event->article;
|
$article = $event->article;
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ public function handle(NewArticleFetched $event): void
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = ValidationService::validate($article);
|
$article = $validationService->validate($article);
|
||||||
|
|
||||||
if ($article->isValid()) {
|
if ($article->isValid()) {
|
||||||
// Double-check publication doesn't exist (race condition protection)
|
// Double-check publication doesn't exist (race condition protection)
|
||||||
|
|
@ -37,12 +37,12 @@ public function handle(NewArticleFetched $event): void
|
||||||
if (Setting::isPublishingApprovalsEnabled()) {
|
if (Setting::isPublishingApprovalsEnabled()) {
|
||||||
// If approvals are enabled, only proceed if article is approved
|
// If approvals are enabled, only proceed if article is approved
|
||||||
if ($article->isApproved()) {
|
if ($article->isApproved()) {
|
||||||
event(new ArticleReadyToPublish($article));
|
event(new ArticleApproved($article));
|
||||||
}
|
}
|
||||||
// If not approved, article will wait for manual approval
|
// If not approved, article will wait for manual approval
|
||||||
} else {
|
} else {
|
||||||
// If approvals are disabled, proceed with publishing
|
// If approvals are disabled, proceed with publishing
|
||||||
event(new ArticleReadyToPublish($article));
|
event(new ArticleApproved($article));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
61
app/Livewire/Articles.php
Normal file
61
app/Livewire/Articles.php
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use App\Jobs\ArticleDiscoveryJob;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithPagination;
|
||||||
|
|
||||||
|
class Articles extends Component
|
||||||
|
{
|
||||||
|
use WithPagination;
|
||||||
|
|
||||||
|
public bool $isRefreshing = false;
|
||||||
|
|
||||||
|
public function approve(int $articleId): void
|
||||||
|
{
|
||||||
|
$article = Article::findOrFail($articleId);
|
||||||
|
$article->approve();
|
||||||
|
|
||||||
|
$this->dispatch('article-updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reject(int $articleId): void
|
||||||
|
{
|
||||||
|
$article = Article::findOrFail($articleId);
|
||||||
|
$article->reject();
|
||||||
|
|
||||||
|
$this->dispatch('article-updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refresh(): void
|
||||||
|
{
|
||||||
|
$this->isRefreshing = true;
|
||||||
|
|
||||||
|
ArticleDiscoveryJob::dispatch();
|
||||||
|
|
||||||
|
// Reset after 10 seconds
|
||||||
|
$this->dispatch('refresh-complete')->self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refreshComplete(): void
|
||||||
|
{
|
||||||
|
$this->isRefreshing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$articles = Article::with(['feed', 'articlePublication'])
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->paginate(15);
|
||||||
|
|
||||||
|
$approvalsEnabled = Setting::isPublishingApprovalsEnabled();
|
||||||
|
|
||||||
|
return view('livewire.articles', [
|
||||||
|
'articles' => $articles,
|
||||||
|
'approvalsEnabled' => $approvalsEnabled,
|
||||||
|
])->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
73
app/Livewire/Channels.php
Normal file
73
app/Livewire/Channels.php
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\PlatformAccount;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Channels extends Component
|
||||||
|
{
|
||||||
|
public ?int $managingChannelId = null;
|
||||||
|
|
||||||
|
public function toggle(int $channelId): void
|
||||||
|
{
|
||||||
|
$channel = PlatformChannel::findOrFail($channelId);
|
||||||
|
$channel->is_active = !$channel->is_active;
|
||||||
|
$channel->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function openAccountModal(int $channelId): void
|
||||||
|
{
|
||||||
|
$this->managingChannelId = $channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closeAccountModal(): void
|
||||||
|
{
|
||||||
|
$this->managingChannelId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attachAccount(int $accountId): void
|
||||||
|
{
|
||||||
|
if (!$this->managingChannelId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel = PlatformChannel::findOrFail($this->managingChannelId);
|
||||||
|
|
||||||
|
if (!$channel->platformAccounts()->where('platform_account_id', $accountId)->exists()) {
|
||||||
|
$channel->platformAccounts()->attach($accountId, [
|
||||||
|
'is_active' => true,
|
||||||
|
'priority' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detachAccount(int $channelId, int $accountId): void
|
||||||
|
{
|
||||||
|
$channel = PlatformChannel::findOrFail($channelId);
|
||||||
|
$channel->platformAccounts()->detach($accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$channels = PlatformChannel::with(['platformInstance', 'platformAccounts'])->orderBy('name')->get();
|
||||||
|
$allAccounts = PlatformAccount::where('is_active', true)->get();
|
||||||
|
|
||||||
|
$managingChannel = $this->managingChannelId
|
||||||
|
? PlatformChannel::with('platformAccounts')->find($this->managingChannelId)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$availableAccounts = $managingChannel
|
||||||
|
? $allAccounts->filter(fn($account) => !$managingChannel->platformAccounts->contains('id', $account->id))
|
||||||
|
: collect();
|
||||||
|
|
||||||
|
return view('livewire.channels', [
|
||||||
|
'channels' => $channels,
|
||||||
|
'managingChannel' => $managingChannel,
|
||||||
|
'availableAccounts' => $availableAccounts,
|
||||||
|
])->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Livewire/Dashboard.php
Normal file
36
app/Livewire/Dashboard.php
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Services\DashboardStatsService;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Dashboard extends Component
|
||||||
|
{
|
||||||
|
public string $period = 'today';
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
// Default period
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPeriod(string $period): void
|
||||||
|
{
|
||||||
|
$this->period = $period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$service = app(DashboardStatsService::class);
|
||||||
|
|
||||||
|
$articleStats = $service->getStats($this->period);
|
||||||
|
$systemStats = $service->getSystemStats();
|
||||||
|
$availablePeriods = $service->getAvailablePeriods();
|
||||||
|
|
||||||
|
return view('livewire.dashboard', [
|
||||||
|
'articleStats' => $articleStats,
|
||||||
|
'systemStats' => $systemStats,
|
||||||
|
'availablePeriods' => $availablePeriods,
|
||||||
|
])->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Livewire/Feeds.php
Normal file
25
app/Livewire/Feeds.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Feed;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Feeds extends Component
|
||||||
|
{
|
||||||
|
public function toggle(int $feedId): void
|
||||||
|
{
|
||||||
|
$feed = Feed::findOrFail($feedId);
|
||||||
|
$feed->is_active = !$feed->is_active;
|
||||||
|
$feed->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$feeds = Feed::orderBy('name')->get();
|
||||||
|
|
||||||
|
return view('livewire.feeds', [
|
||||||
|
'feeds' => $feeds,
|
||||||
|
])->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
358
app/Livewire/Onboarding.php
Normal file
358
app/Livewire/Onboarding.php
Normal file
|
|
@ -0,0 +1,358 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Jobs\ArticleDiscoveryJob;
|
||||||
|
use App\Models\Feed;
|
||||||
|
use App\Models\Language;
|
||||||
|
use App\Models\PlatformAccount;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
|
use App\Models\PlatformInstance;
|
||||||
|
use App\Models\Route;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use App\Services\Auth\LemmyAuthService;
|
||||||
|
use App\Services\OnboardingService;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Onboarding extends Component
|
||||||
|
{
|
||||||
|
// Step tracking (1-6: welcome, platform, feed, channel, route, complete)
|
||||||
|
public int $step = 1;
|
||||||
|
|
||||||
|
// Platform form
|
||||||
|
public string $instanceUrl = '';
|
||||||
|
public string $username = '';
|
||||||
|
public string $password = '';
|
||||||
|
public ?array $existingAccount = null;
|
||||||
|
|
||||||
|
// Feed form
|
||||||
|
public string $feedName = '';
|
||||||
|
public string $feedProvider = 'vrt';
|
||||||
|
public ?int $feedLanguageId = null;
|
||||||
|
public string $feedDescription = '';
|
||||||
|
|
||||||
|
// Channel form
|
||||||
|
public string $channelName = '';
|
||||||
|
public ?int $platformInstanceId = null;
|
||||||
|
public ?int $channelLanguageId = null;
|
||||||
|
public string $channelDescription = '';
|
||||||
|
|
||||||
|
// Route form
|
||||||
|
public ?int $routeFeedId = null;
|
||||||
|
public ?int $routeChannelId = null;
|
||||||
|
public int $routePriority = 50;
|
||||||
|
|
||||||
|
// State
|
||||||
|
public array $formErrors = [];
|
||||||
|
public bool $isLoading = false;
|
||||||
|
|
||||||
|
protected LemmyAuthService $lemmyAuthService;
|
||||||
|
|
||||||
|
public function boot(LemmyAuthService $lemmyAuthService): void
|
||||||
|
{
|
||||||
|
$this->lemmyAuthService = $lemmyAuthService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
// Check for existing platform account
|
||||||
|
$account = PlatformAccount::where('is_active', true)->first();
|
||||||
|
if ($account) {
|
||||||
|
$this->existingAccount = [
|
||||||
|
'id' => $account->id,
|
||||||
|
'username' => $account->username,
|
||||||
|
'instance_url' => $account->instance_url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre-fill feed form if exists
|
||||||
|
$feed = Feed::where('is_active', true)->first();
|
||||||
|
if ($feed) {
|
||||||
|
$this->feedName = $feed->name;
|
||||||
|
$this->feedProvider = $feed->provider ?? 'vrt';
|
||||||
|
$this->feedLanguageId = $feed->language_id;
|
||||||
|
$this->feedDescription = $feed->description ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre-fill channel form if exists
|
||||||
|
$channel = PlatformChannel::where('is_active', true)->first();
|
||||||
|
if ($channel) {
|
||||||
|
$this->channelName = $channel->name;
|
||||||
|
$this->platformInstanceId = $channel->platform_instance_id;
|
||||||
|
$this->channelLanguageId = $channel->language_id;
|
||||||
|
$this->channelDescription = $channel->description ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre-fill route form if exists
|
||||||
|
$route = Route::where('is_active', true)->first();
|
||||||
|
if ($route) {
|
||||||
|
$this->routeFeedId = $route->feed_id;
|
||||||
|
$this->routeChannelId = $route->platform_channel_id;
|
||||||
|
$this->routePriority = $route->priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function goToStep(int $step): void
|
||||||
|
{
|
||||||
|
$this->step = $step;
|
||||||
|
$this->formErrors = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextStep(): void
|
||||||
|
{
|
||||||
|
$this->step++;
|
||||||
|
$this->formErrors = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function previousStep(): void
|
||||||
|
{
|
||||||
|
if ($this->step > 1) {
|
||||||
|
$this->step--;
|
||||||
|
$this->formErrors = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function continueWithExistingAccount(): void
|
||||||
|
{
|
||||||
|
$this->nextStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAccount(): void
|
||||||
|
{
|
||||||
|
if ($this->existingAccount) {
|
||||||
|
PlatformAccount::destroy($this->existingAccount['id']);
|
||||||
|
$this->existingAccount = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPlatformAccount(): void
|
||||||
|
{
|
||||||
|
$this->formErrors = [];
|
||||||
|
$this->isLoading = true;
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'instanceUrl' => 'required|string|max:255|regex:/^[a-zA-Z0-9]([a-zA-Z0-9\-\.]*[a-zA-Z0-9])?$/',
|
||||||
|
'username' => 'required|string|max:255',
|
||||||
|
'password' => 'required|string|min:6',
|
||||||
|
], [
|
||||||
|
'instanceUrl.regex' => 'Please enter a valid domain name (e.g., lemmy.world, belgae.social)',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$fullInstanceUrl = 'https://' . $this->instanceUrl;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create or get platform instance
|
||||||
|
$platformInstance = PlatformInstance::firstOrCreate([
|
||||||
|
'url' => $fullInstanceUrl,
|
||||||
|
'platform' => 'lemmy',
|
||||||
|
], [
|
||||||
|
'name' => ucfirst($this->instanceUrl),
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Authenticate with Lemmy API
|
||||||
|
$authResponse = $this->lemmyAuthService->authenticate(
|
||||||
|
$fullInstanceUrl,
|
||||||
|
$this->username,
|
||||||
|
$this->password
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create platform account
|
||||||
|
$platformAccount = PlatformAccount::create([
|
||||||
|
'platform' => 'lemmy',
|
||||||
|
'instance_url' => $fullInstanceUrl,
|
||||||
|
'username' => $this->username,
|
||||||
|
'password' => Crypt::encryptString($this->password),
|
||||||
|
'settings' => [
|
||||||
|
'display_name' => $authResponse['person_view']['person']['display_name'] ?? null,
|
||||||
|
'description' => $authResponse['person_view']['person']['bio'] ?? null,
|
||||||
|
'person_id' => $authResponse['person_view']['person']['id'] ?? null,
|
||||||
|
'platform_instance_id' => $platformInstance->id,
|
||||||
|
'api_token' => $authResponse['jwt'] ?? null,
|
||||||
|
],
|
||||||
|
'is_active' => true,
|
||||||
|
'status' => 'active',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->existingAccount = [
|
||||||
|
'id' => $platformAccount->id,
|
||||||
|
'username' => $platformAccount->username,
|
||||||
|
'instance_url' => $platformAccount->instance_url,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->nextStep();
|
||||||
|
} catch (\App\Exceptions\PlatformAuthException $e) {
|
||||||
|
$message = $e->getMessage();
|
||||||
|
if (str_contains($message, 'Rate limited by')) {
|
||||||
|
$this->formErrors['general'] = $message;
|
||||||
|
} elseif (str_contains($message, 'Connection failed')) {
|
||||||
|
$this->formErrors['general'] = 'Unable to connect to the Lemmy instance. Please check the URL and try again.';
|
||||||
|
} else {
|
||||||
|
$this->formErrors['general'] = 'Invalid username or password. Please check your credentials and try again.';
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
logger()->error('Lemmy platform account creation failed', [
|
||||||
|
'instance_url' => $fullInstanceUrl,
|
||||||
|
'username' => $this->username,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'class' => get_class($e),
|
||||||
|
]);
|
||||||
|
$this->formErrors['general'] = 'An error occurred while setting up your account. Please try again.';
|
||||||
|
} finally {
|
||||||
|
$this->isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createFeed(): void
|
||||||
|
{
|
||||||
|
$this->formErrors = [];
|
||||||
|
$this->isLoading = true;
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'feedName' => 'required|string|max:255',
|
||||||
|
'feedProvider' => 'required|in:belga,vrt',
|
||||||
|
'feedLanguageId' => 'required|exists:languages,id',
|
||||||
|
'feedDescription' => 'nullable|string|max:1000',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Map provider to URL
|
||||||
|
$url = $this->feedProvider === 'vrt'
|
||||||
|
? 'https://www.vrt.be/vrtnws/en/'
|
||||||
|
: 'https://www.belganewsagency.eu/';
|
||||||
|
|
||||||
|
Feed::firstOrCreate(
|
||||||
|
['url' => $url],
|
||||||
|
[
|
||||||
|
'name' => $this->feedName,
|
||||||
|
'type' => 'website',
|
||||||
|
'provider' => $this->feedProvider,
|
||||||
|
'language_id' => $this->feedLanguageId,
|
||||||
|
'description' => $this->feedDescription ?: null,
|
||||||
|
'is_active' => true,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->nextStep();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->formErrors['general'] = 'Failed to create feed. Please try again.';
|
||||||
|
} finally {
|
||||||
|
$this->isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createChannel(): void
|
||||||
|
{
|
||||||
|
$this->formErrors = [];
|
||||||
|
$this->isLoading = true;
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'channelName' => 'required|string|max:255',
|
||||||
|
'platformInstanceId' => 'required|exists:platform_instances,id',
|
||||||
|
'channelLanguageId' => 'required|exists:languages,id',
|
||||||
|
'channelDescription' => 'nullable|string|max:1000',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$platformInstance = PlatformInstance::findOrFail($this->platformInstanceId);
|
||||||
|
|
||||||
|
// Check for active platform accounts
|
||||||
|
$activeAccounts = PlatformAccount::where('instance_url', $platformInstance->url)
|
||||||
|
->where('is_active', true)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($activeAccounts->isEmpty()) {
|
||||||
|
$this->formErrors['general'] = 'No active platform accounts found for this instance. Please create a platform account first.';
|
||||||
|
$this->isLoading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel = PlatformChannel::create([
|
||||||
|
'platform_instance_id' => $this->platformInstanceId,
|
||||||
|
'channel_id' => $this->channelName,
|
||||||
|
'name' => $this->channelName,
|
||||||
|
'display_name' => ucfirst($this->channelName),
|
||||||
|
'description' => $this->channelDescription ?: null,
|
||||||
|
'language_id' => $this->channelLanguageId,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Attach first active account
|
||||||
|
$channel->platformAccounts()->attach($activeAccounts->first()->id, [
|
||||||
|
'is_active' => true,
|
||||||
|
'priority' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->nextStep();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->formErrors['general'] = 'Failed to create channel. Please try again.';
|
||||||
|
} finally {
|
||||||
|
$this->isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createRoute(): void
|
||||||
|
{
|
||||||
|
$this->formErrors = [];
|
||||||
|
$this->isLoading = true;
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'routeFeedId' => 'required|exists:feeds,id',
|
||||||
|
'routeChannelId' => 'required|exists:platform_channels,id',
|
||||||
|
'routePriority' => 'nullable|integer|min:1|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Route::create([
|
||||||
|
'feed_id' => $this->routeFeedId,
|
||||||
|
'platform_channel_id' => $this->routeChannelId,
|
||||||
|
'priority' => $this->routePriority,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Trigger article discovery
|
||||||
|
ArticleDiscoveryJob::dispatch();
|
||||||
|
|
||||||
|
$this->nextStep();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->formErrors['general'] = 'Failed to create route. Please try again.';
|
||||||
|
} finally {
|
||||||
|
$this->isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function completeOnboarding(): void
|
||||||
|
{
|
||||||
|
Setting::updateOrCreate(
|
||||||
|
['key' => 'onboarding_completed'],
|
||||||
|
['value' => now()->toIso8601String()]
|
||||||
|
);
|
||||||
|
|
||||||
|
app(OnboardingService::class)->clearCache();
|
||||||
|
|
||||||
|
$this->redirect(route('dashboard'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$languages = Language::where('is_active', true)->orderBy('name')->get();
|
||||||
|
$platformInstances = PlatformInstance::where('is_active', true)->orderBy('name')->get();
|
||||||
|
$feeds = Feed::where('is_active', true)->orderBy('name')->get();
|
||||||
|
$channels = PlatformChannel::where('is_active', true)->orderBy('name')->get();
|
||||||
|
|
||||||
|
$feedProviders = collect(config('feed.providers', []))
|
||||||
|
->filter(fn($provider) => $provider['is_active'] ?? false)
|
||||||
|
->values();
|
||||||
|
|
||||||
|
return view('livewire.onboarding', [
|
||||||
|
'languages' => $languages,
|
||||||
|
'platformInstances' => $platformInstances,
|
||||||
|
'feeds' => $feeds,
|
||||||
|
'channels' => $channels,
|
||||||
|
'feedProviders' => $feedProviders,
|
||||||
|
])->layout('layouts.onboarding');
|
||||||
|
}
|
||||||
|
}
|
||||||
200
app/Livewire/Routes.php
Normal file
200
app/Livewire/Routes.php
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Feed;
|
||||||
|
use App\Models\Keyword;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
|
use App\Models\Route;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Routes extends Component
|
||||||
|
{
|
||||||
|
public bool $showCreateModal = false;
|
||||||
|
public ?int $editingFeedId = null;
|
||||||
|
public ?int $editingChannelId = null;
|
||||||
|
|
||||||
|
// Create form
|
||||||
|
public ?int $newFeedId = null;
|
||||||
|
public ?int $newChannelId = null;
|
||||||
|
public int $newPriority = 50;
|
||||||
|
|
||||||
|
// Edit form
|
||||||
|
public int $editPriority = 50;
|
||||||
|
|
||||||
|
// Keyword management
|
||||||
|
public string $newKeyword = '';
|
||||||
|
public bool $showKeywordInput = false;
|
||||||
|
|
||||||
|
public function openCreateModal(): void
|
||||||
|
{
|
||||||
|
$this->showCreateModal = true;
|
||||||
|
$this->newFeedId = null;
|
||||||
|
$this->newChannelId = null;
|
||||||
|
$this->newPriority = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closeCreateModal(): void
|
||||||
|
{
|
||||||
|
$this->showCreateModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createRoute(): void
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'newFeedId' => 'required|exists:feeds,id',
|
||||||
|
'newChannelId' => 'required|exists:platform_channels,id',
|
||||||
|
'newPriority' => 'required|integer|min:0',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$exists = Route::where('feed_id', $this->newFeedId)
|
||||||
|
->where('platform_channel_id', $this->newChannelId)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
$this->addError('newFeedId', 'This route already exists.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Route::create([
|
||||||
|
'feed_id' => $this->newFeedId,
|
||||||
|
'platform_channel_id' => $this->newChannelId,
|
||||||
|
'priority' => $this->newPriority,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->closeCreateModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function openEditModal(int $feedId, int $channelId): void
|
||||||
|
{
|
||||||
|
$route = Route::where('feed_id', $feedId)
|
||||||
|
->where('platform_channel_id', $channelId)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$this->editingFeedId = $feedId;
|
||||||
|
$this->editingChannelId = $channelId;
|
||||||
|
$this->editPriority = $route->priority;
|
||||||
|
$this->newKeyword = '';
|
||||||
|
$this->showKeywordInput = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closeEditModal(): void
|
||||||
|
{
|
||||||
|
$this->editingFeedId = null;
|
||||||
|
$this->editingChannelId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateRoute(): void
|
||||||
|
{
|
||||||
|
if (!$this->editingFeedId || !$this->editingChannelId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'editPriority' => 'required|integer|min:0',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Route::where('feed_id', $this->editingFeedId)
|
||||||
|
->where('platform_channel_id', $this->editingChannelId)
|
||||||
|
->update(['priority' => $this->editPriority]);
|
||||||
|
|
||||||
|
$this->closeEditModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggle(int $feedId, int $channelId): void
|
||||||
|
{
|
||||||
|
$route = Route::where('feed_id', $feedId)
|
||||||
|
->where('platform_channel_id', $channelId)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$route->is_active = !$route->is_active;
|
||||||
|
$route->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(int $feedId, int $channelId): void
|
||||||
|
{
|
||||||
|
// Delete associated keywords first
|
||||||
|
Keyword::where('feed_id', $feedId)
|
||||||
|
->where('platform_channel_id', $channelId)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
Route::where('feed_id', $feedId)
|
||||||
|
->where('platform_channel_id', $channelId)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addKeyword(): void
|
||||||
|
{
|
||||||
|
if (!$this->editingFeedId || !$this->editingChannelId || empty(trim($this->newKeyword))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keyword::create([
|
||||||
|
'feed_id' => $this->editingFeedId,
|
||||||
|
'platform_channel_id' => $this->editingChannelId,
|
||||||
|
'keyword' => trim($this->newKeyword),
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->newKeyword = '';
|
||||||
|
$this->showKeywordInput = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleKeyword(int $keywordId): void
|
||||||
|
{
|
||||||
|
$keyword = Keyword::findOrFail($keywordId);
|
||||||
|
$keyword->is_active = !$keyword->is_active;
|
||||||
|
$keyword->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteKeyword(int $keywordId): void
|
||||||
|
{
|
||||||
|
Keyword::destroy($keywordId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$routes = Route::with(['feed', 'platformChannel'])
|
||||||
|
->orderBy('priority', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Batch load keywords for all routes to avoid N+1 queries
|
||||||
|
$routeKeys = $routes->map(fn($r) => $r->feed_id . '-' . $r->platform_channel_id);
|
||||||
|
$allKeywords = Keyword::whereIn('feed_id', $routes->pluck('feed_id'))
|
||||||
|
->whereIn('platform_channel_id', $routes->pluck('platform_channel_id'))
|
||||||
|
->get()
|
||||||
|
->groupBy(fn($k) => $k->feed_id . '-' . $k->platform_channel_id);
|
||||||
|
|
||||||
|
$routes = $routes->map(function ($route) use ($allKeywords) {
|
||||||
|
$key = $route->feed_id . '-' . $route->platform_channel_id;
|
||||||
|
$route->keywords = $allKeywords->get($key, collect());
|
||||||
|
return $route;
|
||||||
|
});
|
||||||
|
|
||||||
|
$feeds = Feed::where('is_active', true)->orderBy('name')->get();
|
||||||
|
$channels = PlatformChannel::where('is_active', true)->orderBy('name')->get();
|
||||||
|
|
||||||
|
$editingRoute = null;
|
||||||
|
$editingKeywords = collect();
|
||||||
|
|
||||||
|
if ($this->editingFeedId && $this->editingChannelId) {
|
||||||
|
$editingRoute = Route::with(['feed', 'platformChannel'])
|
||||||
|
->where('feed_id', $this->editingFeedId)
|
||||||
|
->where('platform_channel_id', $this->editingChannelId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$editingKeywords = Keyword::where('feed_id', $this->editingFeedId)
|
||||||
|
->where('platform_channel_id', $this->editingChannelId)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('livewire.routes', [
|
||||||
|
'routes' => $routes,
|
||||||
|
'feeds' => $feeds,
|
||||||
|
'channels' => $channels,
|
||||||
|
'editingRoute' => $editingRoute,
|
||||||
|
'editingKeywords' => $editingKeywords,
|
||||||
|
])->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/Livewire/Settings.php
Normal file
55
app/Livewire/Settings.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Settings extends Component
|
||||||
|
{
|
||||||
|
public bool $articleProcessingEnabled = true;
|
||||||
|
public bool $publishingApprovalsEnabled = false;
|
||||||
|
|
||||||
|
public ?string $successMessage = null;
|
||||||
|
public ?string $errorMessage = null;
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->articleProcessingEnabled = Setting::isArticleProcessingEnabled();
|
||||||
|
$this->publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleArticleProcessing(): void
|
||||||
|
{
|
||||||
|
$this->articleProcessingEnabled = !$this->articleProcessingEnabled;
|
||||||
|
Setting::setArticleProcessingEnabled($this->articleProcessingEnabled);
|
||||||
|
$this->showSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function togglePublishingApprovals(): void
|
||||||
|
{
|
||||||
|
$this->publishingApprovalsEnabled = !$this->publishingApprovalsEnabled;
|
||||||
|
Setting::setPublishingApprovalsEnabled($this->publishingApprovalsEnabled);
|
||||||
|
$this->showSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function showSuccess(): void
|
||||||
|
{
|
||||||
|
$this->successMessage = 'Settings updated successfully!';
|
||||||
|
$this->errorMessage = null;
|
||||||
|
|
||||||
|
// Clear success message after 3 seconds
|
||||||
|
$this->dispatch('clear-message');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearMessages(): void
|
||||||
|
{
|
||||||
|
$this->successMessage = null;
|
||||||
|
$this->errorMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.settings')->layout('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,13 +35,11 @@ class Article extends Model
|
||||||
'url',
|
'url',
|
||||||
'title',
|
'title',
|
||||||
'description',
|
'description',
|
||||||
'is_valid',
|
'content',
|
||||||
'is_duplicate',
|
'image_url',
|
||||||
|
'published_at',
|
||||||
|
'author',
|
||||||
'approval_status',
|
'approval_status',
|
||||||
'approved_at',
|
|
||||||
'approved_by',
|
|
||||||
'fetched_at',
|
|
||||||
'validated_at',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,12 +48,8 @@ class Article extends Model
|
||||||
public function casts(): array
|
public function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'is_valid' => 'boolean',
|
|
||||||
'is_duplicate' => 'boolean',
|
|
||||||
'approval_status' => 'string',
|
'approval_status' => 'string',
|
||||||
'approved_at' => 'datetime',
|
'published_at' => 'datetime',
|
||||||
'fetched_at' => 'datetime',
|
|
||||||
'validated_at' => 'datetime',
|
|
||||||
'created_at' => 'datetime',
|
'created_at' => 'datetime',
|
||||||
'updated_at' => 'datetime',
|
'updated_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
@ -63,15 +57,9 @@ public function casts(): array
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
{
|
{
|
||||||
if (is_null($this->validated_at)) {
|
// In the consolidated schema, we only have approval_status
|
||||||
return false;
|
// Consider 'approved' status as valid
|
||||||
}
|
return $this->approval_status === 'approved';
|
||||||
|
|
||||||
if (is_null($this->is_valid)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->is_valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isApproved(): bool
|
public function isApproved(): bool
|
||||||
|
|
@ -93,8 +81,6 @@ public function approve(string $approvedBy = null): void
|
||||||
{
|
{
|
||||||
$this->update([
|
$this->update([
|
||||||
'approval_status' => 'approved',
|
'approval_status' => 'approved',
|
||||||
'approved_at' => now(),
|
|
||||||
'approved_by' => $approvedBy,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Fire event to trigger publishing
|
// Fire event to trigger publishing
|
||||||
|
|
@ -105,8 +91,6 @@ public function reject(string $rejectedBy = null): void
|
||||||
{
|
{
|
||||||
$this->update([
|
$this->update([
|
||||||
'approval_status' => 'rejected',
|
'approval_status' => 'rejected',
|
||||||
'approved_at' => now(),
|
|
||||||
'approved_by' => $rejectedBy,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,6 +109,11 @@ public function canBePublished(): bool
|
||||||
return $this->isApproved();
|
return $this->isApproved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIsPublishedAttribute(): bool
|
||||||
|
{
|
||||||
|
return $this->articlePublication()->exists();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasOne<ArticlePublication, $this>
|
* @return HasOne<ArticlePublication, $this>
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $url
|
* @property string $url
|
||||||
* @property string $type
|
* @property string $type
|
||||||
|
* @property string $provider
|
||||||
* @property int $language_id
|
* @property int $language_id
|
||||||
* @property Language|null $language
|
* @property Language|null $language
|
||||||
* @property string $description
|
* @property string $description
|
||||||
|
|
@ -38,6 +39,7 @@ class Feed extends Model
|
||||||
'name',
|
'name',
|
||||||
'url',
|
'url',
|
||||||
'type',
|
'type',
|
||||||
|
'provider',
|
||||||
'language_id',
|
'language_id',
|
||||||
'description',
|
'description',
|
||||||
'settings',
|
'settings',
|
||||||
|
|
@ -87,7 +89,7 @@ public function getStatusAttribute(): string
|
||||||
public function channels(): BelongsToMany
|
public function channels(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(PlatformChannel::class, 'routes')
|
return $this->belongsToMany(PlatformChannel::class, 'routes')
|
||||||
->withPivot(['is_active', 'priority', 'filters'])
|
->withPivot(['is_active', 'priority'])
|
||||||
->withTimestamps();
|
->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +39,6 @@ class PlatformAccount extends Model
|
||||||
'instance_url',
|
'instance_url',
|
||||||
'username',
|
'username',
|
||||||
'password',
|
'password',
|
||||||
'api_token',
|
|
||||||
'settings',
|
'settings',
|
||||||
'is_active',
|
'is_active',
|
||||||
'last_tested_at',
|
'last_tested_at',
|
||||||
|
|
@ -60,22 +59,40 @@ class PlatformAccount extends Model
|
||||||
protected function password(): Attribute
|
protected function password(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: fn ($value) => $value ? Crypt::decryptString($value) : null,
|
get: function ($value, array $attributes) {
|
||||||
set: fn ($value) => $value ? Crypt::encryptString($value) : null,
|
// Return null if the raw value is null
|
||||||
);
|
if (is_null($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return empty string if value is empty
|
||||||
|
if (empty($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Crypt::decryptString($value);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// If decryption fails, return null to be safe
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set: function ($value) {
|
||||||
|
// Store null if null is passed
|
||||||
|
if (is_null($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store empty string as null
|
||||||
|
if (empty($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Crypt::encryptString($value);
|
||||||
|
},
|
||||||
|
)->withoutObjectCaching();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt API token when storing
|
|
||||||
/**
|
|
||||||
* @return Attribute<string|null, string|null>
|
|
||||||
*/
|
|
||||||
protected function apiToken(): Attribute
|
|
||||||
{
|
|
||||||
return Attribute::make(
|
|
||||||
get: fn ($value) => $value ? Crypt::decryptString($value) : null,
|
|
||||||
set: fn ($value) => $value ? Crypt::encryptString($value) : null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the active accounts for a platform (returns collection)
|
// Get the active accounts for a platform (returns collection)
|
||||||
/**
|
/**
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method static findMany(mixed $channel_ids)
|
* @method static findMany(mixed $channel_ids)
|
||||||
|
* @method static create(array $array)
|
||||||
* @property integer $id
|
* @property integer $id
|
||||||
* @property integer $platform_instance_id
|
* @property integer $platform_instance_id
|
||||||
* @property PlatformInstance $platformInstance
|
* @property PlatformInstance $platformInstance
|
||||||
|
|
@ -78,7 +79,7 @@ public function getFullNameAttribute(): string
|
||||||
public function feeds(): BelongsToMany
|
public function feeds(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Feed::class, 'routes')
|
return $this->belongsToMany(Feed::class, 'routes')
|
||||||
->withPivot(['is_active', 'priority', 'filters'])
|
->withPivot(['is_active', 'priority'])
|
||||||
->withTimestamps();
|
->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\PlatformEnum;
|
use App\Enums\PlatformEnum;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -11,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
class PlatformChannelPost extends Model
|
class PlatformChannelPost extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'platform',
|
'platform',
|
||||||
'channel_id',
|
'channel_id',
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
* @property int $platform_channel_id
|
* @property int $platform_channel_id
|
||||||
* @property bool $is_active
|
* @property bool $is_active
|
||||||
* @property int $priority
|
* @property int $priority
|
||||||
* @property array<string, mixed> $filters
|
|
||||||
* @property Carbon $created_at
|
* @property Carbon $created_at
|
||||||
* @property Carbon $updated_at
|
* @property Carbon $updated_at
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,13 +32,11 @@ class Route extends Model
|
||||||
'feed_id',
|
'feed_id',
|
||||||
'platform_channel_id',
|
'platform_channel_id',
|
||||||
'is_active',
|
'is_active',
|
||||||
'priority',
|
'priority'
|
||||||
'filters'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'is_active' => 'boolean',
|
'is_active' => 'boolean'
|
||||||
'filters' => 'array'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,6 +63,11 @@ public function login(string $username, string $password): ?string
|
||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return $data['jwt'] ?? null;
|
return $data['jwt'] ?? null;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
// Re-throw rate limit exceptions immediately
|
||||||
|
if (str_contains($e->getMessage(), 'Rate limited')) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
logger()->error('Lemmy login exception', ['error' => $e->getMessage(), 'scheme' => $scheme]);
|
logger()->error('Lemmy login exception', ['error' => $e->getMessage(), 'scheme' => $scheme]);
|
||||||
// If this was the first attempt and HTTPS, try HTTP next
|
// If this was the first attempt and HTTPS, try HTTP next
|
||||||
if ($idx === 0 && in_array('http', $schemesToTry, true)) {
|
if ($idx === 0 && in_array('http', $schemesToTry, true)) {
|
||||||
|
|
@ -28,16 +28,21 @@ public function __construct(PlatformAccount $account)
|
||||||
*/
|
*/
|
||||||
public function publishToChannel(Article $article, array $extractedData, PlatformChannel $channel): array
|
public function publishToChannel(Article $article, array $extractedData, PlatformChannel $channel): array
|
||||||
{
|
{
|
||||||
$token = LemmyAuthService::getToken($this->account);
|
$token = resolve(LemmyAuthService::class)->getToken($this->account);
|
||||||
|
|
||||||
// Use the language ID from extracted data (should be set during validation)
|
// Use the language ID from extracted data (should be set during validation)
|
||||||
$languageId = $extractedData['language_id'] ?? null;
|
$languageId = $extractedData['language_id'] ?? null;
|
||||||
|
|
||||||
|
// Resolve community name to numeric ID if needed
|
||||||
|
$communityId = is_numeric($channel->channel_id)
|
||||||
|
? (int) $channel->channel_id
|
||||||
|
: $this->api->getCommunityId($channel->channel_id, $token);
|
||||||
|
|
||||||
return $this->api->createPost(
|
return $this->api->createPost(
|
||||||
$token,
|
$token,
|
||||||
$extractedData['title'] ?? 'Untitled',
|
$extractedData['title'] ?? 'Untitled',
|
||||||
$extractedData['description'] ?? '',
|
$extractedData['description'] ?? '',
|
||||||
(int) $channel->channel_id,
|
$communityId,
|
||||||
$article->url,
|
$article->url,
|
||||||
$extractedData['thumbnail'] ?? null,
|
$extractedData['thumbnail'] ?? null,
|
||||||
$languageId
|
$languageId
|
||||||
|
|
@ -30,16 +30,6 @@ public function boot(): void
|
||||||
\App\Listeners\ValidateArticleListener::class,
|
\App\Listeners\ValidateArticleListener::class,
|
||||||
);
|
);
|
||||||
|
|
||||||
Event::listen(
|
|
||||||
\App\Events\ArticleApproved::class,
|
|
||||||
\App\Listeners\PublishApprovedArticle::class,
|
|
||||||
);
|
|
||||||
|
|
||||||
Event::listen(
|
|
||||||
\App\Events\ArticleReadyToPublish::class,
|
|
||||||
\App\Listeners\PublishArticle::class,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
app()->make(ExceptionHandler::class)
|
app()->make(ExceptionHandler::class)
|
||||||
->reportable(function (Throwable $e) {
|
->reportable(function (Throwable $e) {
|
||||||
|
|
@ -13,18 +13,22 @@
|
||||||
|
|
||||||
class ArticleFetcher
|
class ArticleFetcher
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
private LogSaver $logSaver
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, Article>
|
* @return Collection<int, Article>
|
||||||
*/
|
*/
|
||||||
public static function getArticlesFromFeed(Feed $feed): Collection
|
public function getArticlesFromFeed(Feed $feed): Collection
|
||||||
{
|
{
|
||||||
if ($feed->type === 'rss') {
|
if ($feed->type === 'rss') {
|
||||||
return self::getArticlesFromRssFeed($feed);
|
return $this->getArticlesFromRssFeed($feed);
|
||||||
} elseif ($feed->type === 'website') {
|
} elseif ($feed->type === 'website') {
|
||||||
return self::getArticlesFromWebsiteFeed($feed);
|
return $this->getArticlesFromWebsiteFeed($feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSaver::warning("Unsupported feed type", null, [
|
$this->logSaver->warning("Unsupported feed type", null, [
|
||||||
'feed_id' => $feed->id,
|
'feed_id' => $feed->id,
|
||||||
'feed_type' => $feed->type
|
'feed_type' => $feed->type
|
||||||
]);
|
]);
|
||||||
|
|
@ -35,7 +39,7 @@ public static function getArticlesFromFeed(Feed $feed): Collection
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, Article>
|
* @return Collection<int, Article>
|
||||||
*/
|
*/
|
||||||
private static function getArticlesFromRssFeed(Feed $feed): Collection
|
private function getArticlesFromRssFeed(Feed $feed): Collection
|
||||||
{
|
{
|
||||||
// TODO: Implement RSS feed parsing
|
// TODO: Implement RSS feed parsing
|
||||||
// For now, return empty collection
|
// For now, return empty collection
|
||||||
|
|
@ -45,14 +49,14 @@ private static function getArticlesFromRssFeed(Feed $feed): Collection
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, Article>
|
* @return Collection<int, Article>
|
||||||
*/
|
*/
|
||||||
private static function getArticlesFromWebsiteFeed(Feed $feed): Collection
|
private function getArticlesFromWebsiteFeed(Feed $feed): Collection
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Try to get parser for this feed
|
// Try to get parser for this feed
|
||||||
$parser = HomepageParserFactory::getParserForFeed($feed);
|
$parser = HomepageParserFactory::getParserForFeed($feed);
|
||||||
|
|
||||||
if (! $parser) {
|
if (! $parser) {
|
||||||
LogSaver::warning("No parser available for feed URL", null, [
|
$this->logSaver->warning("No parser available for feed URL", null, [
|
||||||
'feed_id' => $feed->id,
|
'feed_id' => $feed->id,
|
||||||
'feed_url' => $feed->url
|
'feed_url' => $feed->url
|
||||||
]);
|
]);
|
||||||
|
|
@ -64,10 +68,10 @@ private static function getArticlesFromWebsiteFeed(Feed $feed): Collection
|
||||||
$urls = $parser->extractArticleUrls($html);
|
$urls = $parser->extractArticleUrls($html);
|
||||||
|
|
||||||
return collect($urls)
|
return collect($urls)
|
||||||
->map(fn (string $url) => self::saveArticle($url, $feed->id));
|
->map(fn (string $url) => $this->saveArticle($url, $feed->id));
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
LogSaver::error("Failed to fetch articles from website feed", null, [
|
$this->logSaver->error("Failed to fetch articles from website feed", null, [
|
||||||
'feed_id' => $feed->id,
|
'feed_id' => $feed->id,
|
||||||
'feed_url' => $feed->url,
|
'feed_url' => $feed->url,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
|
|
@ -80,7 +84,7 @@ private static function getArticlesFromWebsiteFeed(Feed $feed): Collection
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public static function fetchArticleData(Article $article): array
|
public function fetchArticleData(Article $article): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$html = HttpFetcher::fetchHtml($article->url);
|
$html = HttpFetcher::fetchHtml($article->url);
|
||||||
|
|
@ -88,7 +92,7 @@ public static function fetchArticleData(Article $article): array
|
||||||
|
|
||||||
return $parser->extractData($html);
|
return $parser->extractData($html);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
LogSaver::error('Exception while fetching article data', null, [
|
$this->logSaver->error('Exception while fetching article data', null, [
|
||||||
'url' => $article->url,
|
'url' => $article->url,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
|
|
@ -97,7 +101,7 @@ public static function fetchArticleData(Article $article): array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function saveArticle(string $url, ?int $feedId = null): Article
|
private function saveArticle(string $url, ?int $feedId = null): Article
|
||||||
{
|
{
|
||||||
$existingArticle = Article::where('url', $url)->first();
|
$existingArticle = Article::where('url', $url)->first();
|
||||||
|
|
||||||
|
|
@ -105,9 +109,37 @@ private static function saveArticle(string $url, ?int $feedId = null): Article
|
||||||
return $existingArticle;
|
return $existingArticle;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Article::create([
|
// Extract a basic title from URL as fallback
|
||||||
'url' => $url,
|
$fallbackTitle = $this->generateFallbackTitle($url);
|
||||||
'feed_id' => $feedId
|
|
||||||
]);
|
try {
|
||||||
|
return Article::create([
|
||||||
|
'url' => $url,
|
||||||
|
'feed_id' => $feedId,
|
||||||
|
'title' => $fallbackTitle,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logSaver->error("Failed to create article - title validation failed", null, [
|
||||||
|
'url' => $url,
|
||||||
|
'feed_id' => $feedId,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'suggestion' => 'Check regex parsing patterns for title extraction'
|
||||||
|
]);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateFallbackTitle(string $url): string
|
||||||
|
{
|
||||||
|
// Extract filename from URL as a basic fallback title
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$filename = basename($path ?: $url);
|
||||||
|
|
||||||
|
// Remove file extension and convert to readable format
|
||||||
|
$title = preg_replace('/\.[^.]*$/', '', $filename);
|
||||||
|
$title = str_replace(['-', '_'], ' ', $title);
|
||||||
|
$title = ucwords($title);
|
||||||
|
|
||||||
|
return $title ?: 'Untitled Article';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,20 +6,23 @@
|
||||||
|
|
||||||
class ValidationService
|
class ValidationService
|
||||||
{
|
{
|
||||||
public static function validate(Article $article): Article
|
public function __construct(
|
||||||
|
private ArticleFetcher $articleFetcher
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function validate(Article $article): Article
|
||||||
{
|
{
|
||||||
logger('Checking keywords for article: ' . $article->id);
|
logger('Checking keywords for article: ' . $article->id);
|
||||||
|
|
||||||
$articleData = ArticleFetcher::fetchArticleData($article);
|
$articleData = $this->articleFetcher->fetchArticleData($article);
|
||||||
|
|
||||||
// Update article with fetched metadata (title, description)
|
// Update article with fetched metadata (title, description)
|
||||||
$updateData = [
|
$updateData = [];
|
||||||
'validated_at' => now(),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!empty($articleData)) {
|
if (!empty($articleData)) {
|
||||||
$updateData['title'] = $articleData['title'] ?? null;
|
$updateData['title'] = $articleData['title'] ?? $article->title;
|
||||||
$updateData['description'] = $articleData['description'] ?? null;
|
$updateData['description'] = $articleData['description'] ?? $article->description;
|
||||||
|
$updateData['content'] = $articleData['full_article'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($articleData['full_article']) || empty($articleData['full_article'])) {
|
if (!isset($articleData['full_article']) || empty($articleData['full_article'])) {
|
||||||
|
|
@ -28,22 +31,22 @@ public static function validate(Article $article): Article
|
||||||
'url' => $article->url
|
'url' => $article->url
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$updateData['is_valid'] = false;
|
$updateData['approval_status'] = 'rejected';
|
||||||
$article->update($updateData);
|
$article->update($updateData);
|
||||||
|
|
||||||
return $article->refresh();
|
return $article->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate using extracted content (not stored)
|
// Validate using extracted content (not stored)
|
||||||
$validationResult = self::validateByKeywords($articleData['full_article']);
|
$validationResult = $this->validateByKeywords($articleData['full_article']);
|
||||||
$updateData['is_valid'] = $validationResult;
|
$updateData['approval_status'] = $validationResult ? 'approved' : 'pending';
|
||||||
|
|
||||||
$article->update($updateData);
|
$article->update($updateData);
|
||||||
|
|
||||||
return $article->refresh();
|
return $article->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function validateByKeywords(string $full_article): bool
|
private function validateByKeywords(string $full_article): bool
|
||||||
{
|
{
|
||||||
// Belgian news content keywords - broader set for Belgian news relevance
|
// Belgian news content keywords - broader set for Belgian news relevance
|
||||||
$keywords = [
|
$keywords = [
|
||||||
|
|
@ -13,15 +13,8 @@ class LemmyAuthService
|
||||||
/**
|
/**
|
||||||
* @throws PlatformAuthException
|
* @throws PlatformAuthException
|
||||||
*/
|
*/
|
||||||
public static function getToken(PlatformAccount $account): string
|
public function getToken(PlatformAccount $account): string
|
||||||
{
|
{
|
||||||
$cacheKey = "lemmy_jwt_token_$account->id";
|
|
||||||
$cachedToken = cache()->get($cacheKey);
|
|
||||||
|
|
||||||
if ($cachedToken) {
|
|
||||||
return $cachedToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $account->username || ! $account->password || ! $account->instance_url) {
|
if (! $account->username || ! $account->password || ! $account->instance_url) {
|
||||||
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Missing credentials for account: ' . $account->username);
|
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Missing credentials for account: ' . $account->username);
|
||||||
}
|
}
|
||||||
|
|
@ -33,9 +26,6 @@ public static function getToken(PlatformAccount $account): string
|
||||||
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Login failed for account: ' . $account->username);
|
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Login failed for account: ' . $account->username);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache for 50 minutes (3000 seconds) to allow buffer before token expires
|
|
||||||
cache()->put($cacheKey, $token, 3000);
|
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Services\Factories;
|
namespace App\Services\Factories;
|
||||||
|
|
||||||
use App\Contracts\ArticleParserInterface;
|
use App\Contracts\ArticleParserInterface;
|
||||||
|
use App\Models\Feed;
|
||||||
use App\Services\Parsers\VrtArticleParser;
|
use App\Services\Parsers\VrtArticleParser;
|
||||||
use App\Services\Parsers\BelgaArticleParser;
|
use App\Services\Parsers\BelgaArticleParser;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
@ -33,6 +34,25 @@ public static function getParser(string $url): ArticleParserInterface
|
||||||
throw new Exception("No parser found for URL: {$url}");
|
throw new Exception("No parser found for URL: {$url}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getParserForFeed(Feed $feed, string $parserType = 'article'): ?ArticleParserInterface
|
||||||
|
{
|
||||||
|
if (!$feed->provider) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$providerConfig = config("feed.providers.{$feed->provider}");
|
||||||
|
if (!$providerConfig || !isset($providerConfig['parsers'][$parserType])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parserClass = $providerConfig['parsers'][$parserType];
|
||||||
|
if (!class_exists($parserClass)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new $parserClass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, string>
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,10 +36,20 @@ public static function getParser(string $url): HomepageParserInterface
|
||||||
|
|
||||||
public static function getParserForFeed(Feed $feed): ?HomepageParserInterface
|
public static function getParserForFeed(Feed $feed): ?HomepageParserInterface
|
||||||
{
|
{
|
||||||
try {
|
if (!$feed->provider) {
|
||||||
return self::getParser($feed->url);
|
|
||||||
} catch (Exception) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$providerConfig = config("feed.providers.{$feed->provider}");
|
||||||
|
if (!$providerConfig || !isset($providerConfig['parsers']['homepage'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parserClass = $providerConfig['parsers']['homepage'];
|
||||||
|
if (!class_exists($parserClass)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new $parserClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,39 +11,39 @@ class LogSaver
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $context
|
* @param array<string, mixed> $context
|
||||||
*/
|
*/
|
||||||
public static function info(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
public function info(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
||||||
{
|
{
|
||||||
self::log(LogLevelEnum::INFO, $message, $channel, $context);
|
$this->log(LogLevelEnum::INFO, $message, $channel, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $context
|
* @param array<string, mixed> $context
|
||||||
*/
|
*/
|
||||||
public static function error(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
public function error(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
||||||
{
|
{
|
||||||
self::log(LogLevelEnum::ERROR, $message, $channel, $context);
|
$this->log(LogLevelEnum::ERROR, $message, $channel, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $context
|
* @param array<string, mixed> $context
|
||||||
*/
|
*/
|
||||||
public static function warning(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
public function warning(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
||||||
{
|
{
|
||||||
self::log(LogLevelEnum::WARNING, $message, $channel, $context);
|
$this->log(LogLevelEnum::WARNING, $message, $channel, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $context
|
* @param array<string, mixed> $context
|
||||||
*/
|
*/
|
||||||
public static function debug(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
public function debug(string $message, ?PlatformChannel $channel = null, array $context = []): void
|
||||||
{
|
{
|
||||||
self::log(LogLevelEnum::DEBUG, $message, $channel, $context);
|
$this->log(LogLevelEnum::DEBUG, $message, $channel, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $context
|
* @param array<string, mixed> $context
|
||||||
*/
|
*/
|
||||||
private static function log(LogLevelEnum $level, string $message, ?PlatformChannel $channel = null, array $context = []): void
|
private function log(LogLevelEnum $level, string $message, ?PlatformChannel $channel = null, array $context = []): void
|
||||||
{
|
{
|
||||||
$logContext = $context;
|
$logContext = $context;
|
||||||
|
|
||||||
46
app/Services/OnboardingService.php
Normal file
46
app/Services/OnboardingService.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Feed;
|
||||||
|
use App\Models\PlatformAccount;
|
||||||
|
use App\Models\PlatformChannel;
|
||||||
|
use App\Models\Route;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
class OnboardingService
|
||||||
|
{
|
||||||
|
public function needsOnboarding(): bool
|
||||||
|
{
|
||||||
|
return Cache::remember('onboarding_needed', 300, function () {
|
||||||
|
return $this->checkOnboardingStatus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearCache(): void
|
||||||
|
{
|
||||||
|
Cache::forget('onboarding_needed');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkOnboardingStatus(): bool
|
||||||
|
{
|
||||||
|
$onboardingSkipped = Setting::where('key', 'onboarding_skipped')->value('value') === 'true';
|
||||||
|
$onboardingCompleted = Setting::where('key', 'onboarding_completed')->exists();
|
||||||
|
|
||||||
|
// If skipped or completed, no onboarding needed
|
||||||
|
if ($onboardingCompleted || $onboardingSkipped) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if all components exist
|
||||||
|
$hasPlatformAccount = PlatformAccount::where('is_active', true)->exists();
|
||||||
|
$hasFeed = Feed::where('is_active', true)->exists();
|
||||||
|
$hasChannel = PlatformChannel::where('is_active', true)->exists();
|
||||||
|
$hasRoute = Route::where('is_active', true)->exists();
|
||||||
|
|
||||||
|
$hasAllComponents = $hasPlatformAccount && $hasFeed && $hasChannel && $hasRoute;
|
||||||
|
|
||||||
|
return !$hasAllComponents;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue