mirror of
https://github.com/Alexander-D-Karpov/webring.git
synced 2026-03-16 22:07:41 +03:00
* major changes
Introduce full user system and approval workflow
——————————————————————————————————————————
Login & sessions
Telegram one‑click login (/login → /auth/telegram) with HMAC verification
New users and sessions tables; telegram_id now optional, TTL‑based cleanup job
Secure session_id cookie (configurable TTL and Secure/SameSite flags)
User dashboard (/user)
Lists the member’s sites and their uptime status
Forms to submit new site or update requests; validation and slug/url sanitisation
View pending requests with change diff
Request storage
update_requests table captures create/update ops as JSONB “changed_fields”
Admin review
/admin/requests interface to approve / reject queued requests
Approval auto‑creates sites (with ordered display_order) or patches existing ones, then refreshes favicon
Super‑admin panel
/admin/setup lists all users, toggle is_admin and forcibly logs them out
Notifications
On every new request, all admins with a Telegram ID receive a Markdown summary via bot API
Public UI tweaks
Header shows login/logout, role‑aware links and call‑to‑action cards
/submit page creates a queued request
Config & env
Added TELEGRAM_BOT_TOKEN, TELEGRAM_BOT_USERNAME, SESSION_TTL_HOURS, SESSION_SECURE_COOKIE
.env.template updated accordingly
Migrations 004–010
Users, sessions, foreign key on sites, display_order, update_requests, telegram_id nullability
BREAKING CHANGE
Environment must supply Telegram bot credentials
Database must be migrated; existing “dashboard” auth remains but admin routes are now session‑protected where applicable
108 lines
3.0 KiB
Makefile
108 lines
3.0 KiB
Makefile
-include .env
|
|
export
|
|
|
|
MIGRATE := migrate -database "${DB_CONNECTION_STRING}" -path migrations
|
|
|
|
.PHONY: migrate-up migrate-down migrate-force migrate-goto migrate-version lint test build clean install-tools run dev
|
|
|
|
# Migration commands
|
|
migrate-up:
|
|
@echo "Running migrations up..."
|
|
@$(MIGRATE) up
|
|
|
|
migrate-down:
|
|
@echo "Running migrations down..."
|
|
@$(MIGRATE) down
|
|
|
|
migrate-force:
|
|
@echo "Forcing migration version..."
|
|
@$(MIGRATE) force $(version)
|
|
|
|
migrate-goto:
|
|
@echo "Migrating to version $(version)..."
|
|
@$(MIGRATE) goto $(version)
|
|
|
|
migrate-version:
|
|
@echo "Checking migration version..."
|
|
@$(MIGRATE) version
|
|
|
|
# Linting and testing
|
|
lint:
|
|
@echo "Running linter..."
|
|
@golangci-lint run
|
|
|
|
lint-fix:
|
|
@echo "Running linter with auto-fix..."
|
|
@golangci-lint run --fix
|
|
|
|
test:
|
|
@echo "Running tests..."
|
|
@go test -v ./...
|
|
|
|
test-coverage:
|
|
@echo "Running tests with coverage..."
|
|
@go test -v -coverprofile=coverage.out ./...
|
|
@go tool cover -html=coverage.out -o coverage.html
|
|
|
|
# Build commands
|
|
build:
|
|
@echo "Building application..."
|
|
@go build -v -o webring cmd/server/main.go
|
|
|
|
build-linux:
|
|
@echo "Building for Linux..."
|
|
@GOOS=linux GOARCH=amd64 go build -v -o webring-linux cmd/server/main.go
|
|
|
|
build-windows:
|
|
@echo "Building for Windows..."
|
|
@GOOS=windows GOARCH=amd64 go build -v -o webring.exe cmd/server/main.go
|
|
|
|
# Development commands
|
|
run:
|
|
@echo "Running application..."
|
|
@go run cmd/server/main.go
|
|
|
|
dev:
|
|
@echo "Running in development mode..."
|
|
@air
|
|
|
|
# Cleanup
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
@rm -f webring webring-linux webring.exe
|
|
@rm -f coverage.out coverage.html
|
|
|
|
# Tool installation
|
|
install-tools:
|
|
@echo "Installing development tools..."
|
|
@go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
|
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
@go install github.com/air-verse/air@latest
|
|
|
|
# Database commands
|
|
db-reset:
|
|
@echo "Resetting database..."
|
|
@$(MIGRATE) down -all
|
|
@$(MIGRATE) up
|
|
|
|
# Help
|
|
help:
|
|
@echo "Available commands:"
|
|
@echo " migrate-up - Run database migrations"
|
|
@echo " migrate-down - Rollback database migrations"
|
|
@echo " migrate-force - Force migration version (use: make migrate-force version=N)"
|
|
@echo " migrate-goto - Go to specific migration (use: make migrate-goto version=N)"
|
|
@echo " migrate-version - Check current migration version"
|
|
@echo " lint - Run golangci-lint"
|
|
@echo " lint-fix - Run golangci-lint with auto-fix"
|
|
@echo " test - Run tests"
|
|
@echo " test-coverage - Run tests with coverage report"
|
|
@echo " build - Build application"
|
|
@echo " build-linux - Build for Linux"
|
|
@echo " build-windows - Build for Windows"
|
|
@echo " run - Run application"
|
|
@echo " dev - Run in development mode with air"
|
|
@echo " clean - Clean build artifacts"
|
|
@echo " install-tools - Install development tools"
|
|
@echo " db-reset - Reset database (down-all then up)"
|
|
@echo " help - Show this help message"
|