Maintain local ⭤ remote in sync with automatic AT Protocol parity for Laravel (alpha & unstable)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add events and jobs

+182
+23
src/Events/ConflictDetected.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Database\Eloquent\Model; 6 + use Illuminate\Foundation\Events\Dispatchable; 7 + use SocialDept\AtpParity\Sync\PendingConflict; 8 + use SocialDept\AtpSchema\Data\Data; 9 + 10 + /** 11 + * Dispatched when a conflict is detected that requires manual resolution. 12 + */ 13 + class ConflictDetected 14 + { 15 + use Dispatchable; 16 + 17 + public function __construct( 18 + public readonly Model $model, 19 + public readonly Data $record, 20 + public readonly array $meta, 21 + public readonly PendingConflict $conflict, 22 + ) {} 23 + }
+15
src/Events/ImportCompleted.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Foundation\Events\Dispatchable; 6 + use SocialDept\AtpParity\Import\ImportResult; 7 + 8 + class ImportCompleted 9 + { 10 + use Dispatchable; 11 + 12 + public function __construct( 13 + public readonly ImportResult $result, 14 + ) {} 15 + }
+16
src/Events/ImportFailed.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Foundation\Events\Dispatchable; 6 + 7 + class ImportFailed 8 + { 9 + use Dispatchable; 10 + 11 + public function __construct( 12 + public readonly string $did, 13 + public readonly string $collection, 14 + public readonly string $error, 15 + ) {} 16 + }
+17
src/Events/ImportProgress.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Foundation\Events\Dispatchable; 6 + 7 + class ImportProgress 8 + { 9 + use Dispatchable; 10 + 11 + public function __construct( 12 + public readonly string $did, 13 + public readonly string $collection, 14 + public readonly int $recordsSynced, 15 + public readonly ?string $cursor = null, 16 + ) {} 17 + }
+15
src/Events/ImportStarted.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Foundation\Events\Dispatchable; 6 + 7 + class ImportStarted 8 + { 9 + use Dispatchable; 10 + 11 + public function __construct( 12 + public readonly string $did, 13 + public readonly string $collection, 14 + ) {} 15 + }
+20
src/Events/RecordPublished.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Database\Eloquent\Model; 6 + use Illuminate\Foundation\Events\Dispatchable; 7 + 8 + /** 9 + * Dispatched when a model is published to AT Protocol. 10 + */ 11 + class RecordPublished 12 + { 13 + use Dispatchable; 14 + 15 + public function __construct( 16 + public readonly Model $model, 17 + public readonly string $uri, 18 + public readonly string $cid, 19 + ) {} 20 + }
+19
src/Events/RecordUnpublished.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Events; 4 + 5 + use Illuminate\Database\Eloquent\Model; 6 + use Illuminate\Foundation\Events\Dispatchable; 7 + 8 + /** 9 + * Dispatched when a model is unpublished from AT Protocol. 10 + */ 11 + class RecordUnpublished 12 + { 13 + use Dispatchable; 14 + 15 + public function __construct( 16 + public readonly Model $model, 17 + public readonly string $uri, 18 + ) {} 19 + }
+57
src/Jobs/ImportUserJob.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpParity\Jobs; 4 + 5 + use Illuminate\Bus\Queueable; 6 + use Illuminate\Contracts\Queue\ShouldQueue; 7 + use Illuminate\Foundation\Bus\Dispatchable; 8 + use Illuminate\Queue\InteractsWithQueue; 9 + use Illuminate\Queue\SerializesModels; 10 + use SocialDept\AtpParity\Import\ImportService; 11 + 12 + class ImportUserJob implements ShouldQueue 13 + { 14 + use Dispatchable; 15 + use InteractsWithQueue; 16 + use Queueable; 17 + use SerializesModels; 18 + 19 + /** 20 + * The number of times the job may be attempted. 21 + */ 22 + public int $tries = 3; 23 + 24 + /** 25 + * The number of seconds to wait before retrying. 26 + */ 27 + public int $backoff = 60; 28 + 29 + public function __construct( 30 + public string $did, 31 + public ?string $collection = null, 32 + ) { 33 + $this->onQueue(config('parity.import.queue', 'default')); 34 + } 35 + 36 + public function handle(ImportService $service): void 37 + { 38 + $collections = $this->collection ? [$this->collection] : null; 39 + $service->importUser($this->did, $collections); 40 + } 41 + 42 + /** 43 + * Get the tags that should be assigned to the job. 44 + * 45 + * @return array<string> 46 + */ 47 + public function tags(): array 48 + { 49 + $tags = ['parity-import', "did:{$this->did}"]; 50 + 51 + if ($this->collection) { 52 + $tags[] = "collection:{$this->collection}"; 53 + } 54 + 55 + return $tags; 56 + } 57 + }