2026-01-15 01:13:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
namespace App\Models;
|
|
|
|
|
|
2026-01-17 15:36:49 +00:00
|
|
|
use App\Enums\PostPlatform\ContentType;
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
use App\Enums\PostPlatform\Status;
|
2026-01-17 17:44:37 +00:00
|
|
|
use App\Enums\SocialAccount\Platform as SocialPlatform;
|
2026-03-29 22:24:28 +00:00
|
|
|
use Database\Factories\PostPlatformFactory;
|
2026-01-15 01:13:44 +00:00
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2026-05-02 15:22:42 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2026-01-15 01:13:44 +00:00
|
|
|
|
|
|
|
|
class PostPlatform extends Model
|
|
|
|
|
{
|
2026-03-29 22:24:28 +00:00
|
|
|
/** @use HasFactory<PostPlatformFactory> */
|
2026-04-15 23:11:36 +00:00
|
|
|
use HasFactory, HasUuids;
|
2026-01-15 01:13:44 +00:00
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'post_id',
|
|
|
|
|
'social_account_id',
|
2026-01-15 17:24:39 +00:00
|
|
|
'enabled',
|
2026-01-15 01:13:44 +00:00
|
|
|
'platform',
|
2026-04-15 23:11:36 +00:00
|
|
|
'platform_name',
|
|
|
|
|
'platform_username',
|
|
|
|
|
'platform_avatar',
|
2026-01-17 15:36:49 +00:00
|
|
|
'content_type',
|
2026-01-15 01:13:44 +00:00
|
|
|
'status',
|
|
|
|
|
'platform_post_id',
|
|
|
|
|
'platform_url',
|
|
|
|
|
'error_message',
|
2026-04-01 14:07:21 +00:00
|
|
|
'error_context',
|
2026-01-15 01:13:44 +00:00
|
|
|
'published_at',
|
|
|
|
|
'meta',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-01-15 17:24:39 +00:00
|
|
|
'enabled' => 'boolean',
|
2026-01-15 01:13:44 +00:00
|
|
|
'platform' => SocialPlatform::class,
|
2026-01-17 15:36:49 +00:00
|
|
|
'content_type' => ContentType::class,
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
'status' => Status::class,
|
2026-01-15 01:13:44 +00:00
|
|
|
'published_at' => 'datetime',
|
|
|
|
|
'meta' => 'array',
|
2026-04-01 14:07:21 +00:00
|
|
|
'error_context' => 'array',
|
2026-01-15 01:13:44 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function post(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Post::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function socialAccount(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(SocialAccount::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 23:11:36 +00:00
|
|
|
/**
|
|
|
|
|
* Get display name, falling back to snapshot if account was deleted.
|
|
|
|
|
*/
|
|
|
|
|
public function getDisplayNameAttribute(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->socialAccount?->display_name ?? $this->platform_name ?? $this->platform->label();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get username, falling back to snapshot if account was deleted.
|
|
|
|
|
*/
|
|
|
|
|
public function getDisplayUsernameAttribute(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->socialAccount?->username ?? $this->platform_username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get avatar URL, falling back to snapshot if account was deleted.
|
|
|
|
|
*/
|
|
|
|
|
public function getDisplayAvatarAttribute(): ?string
|
|
|
|
|
{
|
2026-05-02 15:22:42 +00:00
|
|
|
if ($this->socialAccount?->avatar_url) {
|
|
|
|
|
return $this->socialAccount->avatar_url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->platform_avatar ? Storage::url($this->platform_avatar) : null;
|
2026-04-15 23:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
public function markAsPublishing(): void
|
|
|
|
|
{
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
$this->update(['status' => Status::Publishing]);
|
2026-01-15 01:13:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function markAsPublished(string $platformPostId, ?string $platformUrl = null): void
|
|
|
|
|
{
|
2026-05-02 17:15:41 +00:00
|
|
|
$now = now();
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
$this->update([
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
'status' => Status::Published,
|
2026-01-15 01:13:44 +00:00
|
|
|
'platform_post_id' => $platformPostId,
|
|
|
|
|
'platform_url' => $platformUrl,
|
2026-05-02 17:15:41 +00:00
|
|
|
'published_at' => $now,
|
2026-01-15 01:13:44 +00:00
|
|
|
]);
|
2026-05-02 17:15:41 +00:00
|
|
|
|
|
|
|
|
$this->socialAccount?->update(['last_used_at' => $now]);
|
2026-01-15 01:13:44 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 14:07:21 +00:00
|
|
|
public function markAsFailed(string $errorMessage, ?array $errorContext = null): void
|
2026-01-15 01:13:44 +00:00
|
|
|
{
|
|
|
|
|
$this->update([
|
feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests
Publishing improvements:
- Create PostPlatformStatus enum (Pending, Publishing, Published, Failed)
- Update PostPlatform model, jobs, factories to use enum
- Add PostPublishFailed email notification when post fails to publish
- Maizzle template + blade for failure email with platform details
- PublishPost job: add $tries=3, $backoff=30, failed() method
- Fix broadcast event to serialize enum status value
Security:
- Add rate limiting (throttle:6,1) on social connect endpoints
- Fix MediaController::reorder IDOR vulnerability
- Fix Connect.vue broken import (storeStep2 -> storeConnect)
- Fix UpdatePost data_get() consistency
Database:
- Add composite index on post_platforms (post_id, enabled)
- Add index on post_platforms (social_account_id)
Tests:
- Add 3 tests for profile photo upload/delete
- Add 2 tests for media reorder (including IDOR check)
- Fix publish tests for PostPlatformStatus enum
- Add Mail::fake() to publish tests
Cleanup:
- Remove unused AppHeader.vue and AppHeaderLayout.vue
- Remove dead BillingController methods
All 733 tests passing.
2026-03-30 19:11:38 +00:00
|
|
|
'status' => Status::Failed,
|
2026-01-15 01:13:44 +00:00
|
|
|
'error_message' => $errorMessage,
|
2026-04-01 14:07:21 +00:00
|
|
|
'error_context' => $errorContext,
|
2026-01-15 01:13:44 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|