diff --git a/app/AccountInterstitial.php b/app/AccountInterstitial.php index d2626ab58..5b4a18236 100644 --- a/app/AccountInterstitial.php +++ b/app/AccountInterstitial.php @@ -11,7 +11,10 @@ class AccountInterstitial extends Model * * @var array */ - protected $dates = ['read_at', 'appeal_requested_at']; + protected $casts = [ + 'read_at' => 'datetime', + 'appeal_requested_at' => 'datetime' + ]; public const JSON_MESSAGE = 'Please use web browser to proceed.'; diff --git a/app/Activity.php b/app/Activity.php index 18a4e74de..bfd35c75a 100644 --- a/app/Activity.php +++ b/app/Activity.php @@ -6,7 +6,10 @@ use Illuminate\Database\Eloquent\Model; class Activity extends Model { - protected $dates = ['processed_at']; + protected $casts = [ + 'processed_at' => 'datetime' + ]; + protected $fillable = ['data', 'to_id', 'from_id', 'object_type']; public function toProfile() diff --git a/app/Avatar.php b/app/Avatar.php index d8eece36a..a3abf82f5 100644 --- a/app/Avatar.php +++ b/app/Avatar.php @@ -14,10 +14,10 @@ class Avatar extends Model * * @var array */ - protected $dates = [ - 'deleted_at', - 'last_fetched_at', - 'last_processed_at' + protected $casts = [ + 'deleted_at' => 'datetime', + 'last_fetched_at' => 'datetime', + 'last_processed_at' => 'datetime' ]; protected $guarded = []; diff --git a/app/Console/Commands/VideoThumbnail.php b/app/Console/Commands/VideoThumbnail.php index c2d01aa63..99d28d412 100644 --- a/app/Console/Commands/VideoThumbnail.php +++ b/app/Console/Commands/VideoThumbnail.php @@ -46,7 +46,7 @@ class VideoThumbnail extends Command ->take($limit) ->get(); foreach($videos as $video) { - Pipeline::dispatchNow($video); + Pipeline::dispatchSync($video); } } } diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 15a8958de..603e0403a 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -46,7 +46,7 @@ class ContactController extends Controller $contact->response = ''; $contact->save(); - ContactPipeline::dispatchNow($contact); + ContactPipeline::dispatchSync($contact); return redirect()->back()->with('status', 'Success - Your message has been sent to admins.'); } diff --git a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php index 49daccb67..3ef82eeca 100644 --- a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php +++ b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php @@ -80,7 +80,7 @@ class DeleteAccountPipeline implements ShouldQueue $id = $user->profile_id; Status::whereProfileId($id)->chunk(50, function($statuses) { foreach($statuses as $status) { - StatusDelete::dispatchNow($status); + StatusDelete::dispatchSync($status); } }); diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index 0a0721648..b01604cfe 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -95,7 +95,7 @@ class StatusDelete implements ShouldQueue Media::whereStatusId($status->id) ->get() ->each(function($media) { - MediaDeletePipeline::dispatchNow($media); + MediaDeletePipeline::dispatchSync($media); }); if($status->in_reply_to_id) { diff --git a/app/Like.php b/app/Like.php index 9ba3ca9aa..2c2cd80f9 100644 --- a/app/Like.php +++ b/app/Like.php @@ -16,7 +16,10 @@ class Like extends Model * * @var array */ - protected $dates = ['deleted_at']; + protected $casts = [ + 'deleted_at' => 'datetime' + ]; + protected $fillable = ['profile_id', 'status_id', 'status_profile_id']; public function actor() diff --git a/app/Media.php b/app/Media.php index 9b91f42be..16448dbbf 100644 --- a/app/Media.php +++ b/app/Media.php @@ -17,12 +17,11 @@ class Media extends Model * * @var array */ - protected $dates = ['deleted_at']; - protected $guarded = []; protected $casts = [ - 'srcset' => 'array' + 'srcset' => 'array', + 'deleted_at' => 'datetime' ]; public function status() diff --git a/app/Mention.php b/app/Mention.php index d39399fcb..e0c30d35c 100644 --- a/app/Mention.php +++ b/app/Mention.php @@ -14,7 +14,9 @@ class Mention extends Model * * @var array */ - protected $dates = ['deleted_at']; + protected $casts = [ + 'deleted_at' => 'datetime' + ]; protected $guarded = []; diff --git a/app/Newsroom.php b/app/Newsroom.php index eca57eafc..347aa09b2 100644 --- a/app/Newsroom.php +++ b/app/Newsroom.php @@ -9,7 +9,9 @@ class Newsroom extends Model protected $table = 'newsroom'; protected $fillable = ['title']; - protected $dates = ['published_at']; + protected $casts = [ + 'published_at' => 'datetime' + ]; public function permalink() { diff --git a/app/Notification.php b/app/Notification.php index b0877978f..5dcb8afde 100644 --- a/app/Notification.php +++ b/app/Notification.php @@ -14,7 +14,9 @@ class Notification extends Model * * @var array */ - protected $dates = ['deleted_at']; + protected $casts = [ + 'deleted_at' => 'datetime' + ]; protected $guarded = []; diff --git a/app/Profile.php b/app/Profile.php index 0baa33bf6..5c8d2ccbf 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -19,10 +19,10 @@ class Profile extends Model */ public $incrementing = false; - protected $dates = [ - 'deleted_at', - 'last_fetched_at', - 'last_status_at' + protected $casts = [ + 'deleted_at' => 'datetime', + 'last_fetched_at' => 'datetime', + 'last_status_at' => 'datetime' ]; protected $hidden = ['private_key']; protected $visible = ['id', 'user_id', 'username', 'name']; diff --git a/app/Report.php b/app/Report.php index bafde0b4d..48df52bcb 100644 --- a/app/Report.php +++ b/app/Report.php @@ -6,7 +6,9 @@ use Illuminate\Database\Eloquent\Model; class Report extends Model { - protected $dates = ['admin_seen']; + protected $casts = [ + 'admin_seen' => 'datetime' + ]; protected $guarded = []; diff --git a/app/Status.php b/app/Status.php index 6150a9651..ae4ea299d 100644 --- a/app/Status.php +++ b/app/Status.php @@ -26,7 +26,9 @@ class Status extends Model * * @var array */ - protected $dates = ['deleted_at']; + protected $casts = [ + 'deleted_at' => 'datetime' + ]; protected $guarded = []; diff --git a/app/StoryItem.php b/app/StoryItem.php index 7a87d18ef..0ac345973 100644 --- a/app/StoryItem.php +++ b/app/StoryItem.php @@ -22,7 +22,9 @@ class StoryItem extends Model * * @var array */ - protected $dates = ['expires_at']; + protected $casts = [ + 'expires_at' => 'datetime' + ]; protected $visible = ['id']; diff --git a/app/User.php b/app/User.php index 4bd60a075..6430eac09 100644 --- a/app/User.php +++ b/app/User.php @@ -17,7 +17,11 @@ class User extends Authenticatable * * @var array */ - protected $dates = ['deleted_at', 'email_verified_at', '2fa_setup_at']; + protected $casts = [ + 'deleted_at' => 'datetime', + 'email_verified_at' => 'datetime', + '2fa_setup_at' => 'datetime' + ]; /** * The attributes that are mass assignable. diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 7ea1eb8af..6df783663 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -178,7 +178,7 @@ class Inbox switch($obj['type']) { case 'Story': - StoryFetch::dispatchNow($this->payload); + StoryFetch::dispatchSync($this->payload); break; } diff --git a/config/purify.php b/config/purify.php index 681f55dd6..a06b38166 100644 --- a/config/purify.php +++ b/config/purify.php @@ -1,182 +1,144 @@ [ + 'default' => 'default', - /* - |-------------------------------------------------------------------------- - | Core.Encoding - |-------------------------------------------------------------------------- - | - | The encoding to convert input to. - | - | http://htmlpurifier.org/live/configdoc/plain.html#Core.Encoding - | - */ + /* + |-------------------------------------------------------------------------- + | Config sets + |-------------------------------------------------------------------------- + | + | Here you may configure various sets of configuration for differentiated use of HTMLPurifier. + | A specific set of configuration can be applied by calling the "config($name)" method on + | a Purify instance. Feel free to add/remove/customize these attributes as you wish. + | + | Documentation: http://htmlpurifier.org/live/configdoc/plain.html + | + | Core.Encoding The encoding to convert input to. + | HTML.Doctype Doctype to use during filtering. + | HTML.Allowed The allowed HTML Elements with their allowed attributes. + | HTML.ForbiddenElements The forbidden HTML elements. Elements that are listed in this + | string will be removed, however their content will remain. + | CSS.AllowedProperties The Allowed CSS properties. + | AutoFormat.AutoParagraph Newlines are converted in to paragraphs whenever possible. + | AutoFormat.RemoveEmpty Remove empty elements that contribute no semantic information to the document. + | + */ - 'Core.Encoding' => 'utf-8', + 'configs' => [ - /* - |-------------------------------------------------------------------------- - | Core.SerializerPath - |-------------------------------------------------------------------------- - | - | The HTML purifier serializer cache path. - | - | http://htmlpurifier.org/live/configdoc/plain.html#Cache.SerializerPath - | - */ + 'default' => [ + 'Core.Encoding' => 'utf-8', + 'HTML.Doctype' => 'HTML 4.01 Transitional', - 'Cache.SerializerPath' => storage_path('purify'), - - /* - |-------------------------------------------------------------------------- - | HTML.Doctype - |-------------------------------------------------------------------------- - | - | Doctype to use during filtering. - | - | http://htmlpurifier.org/live/configdoc/plain.html#HTML.Doctype - | - */ - - 'HTML.Doctype' => 'XHTML 1.0 Transitional', - - /* - |-------------------------------------------------------------------------- - | HTML.Allowed - |-------------------------------------------------------------------------- - | - | The allowed HTML Elements with their allowed attributes. - | - | http://htmlpurifier.org/live/configdoc/plain.html#HTML.Allowed - | - */ - - 'HTML.Allowed' => env('RESTRICT_HTML_TYPES', true) ? + 'HTML.Allowed' => env('RESTRICT_HTML_TYPES', true) ? 'a[href|title|rel|class],p[class],span[class],br' : 'a[href|title|rel|class],p[class],span[class],strong,em,del,b,i,s,strike,h1,h2,h3,h4,h5,h6,ul,ol,li,br', + 'HTML.ForbiddenElements' => '', + 'CSS.AllowedProperties' => '', - /* - |-------------------------------------------------------------------------- - | HTML.ForbiddenElements - |-------------------------------------------------------------------------- - | - | The forbidden HTML elements. Elements that are listed in - | this string will be removed, however their content will remain. - | - | For example if 'p' is inside the string, the string: '

Test

', - | - | Will be cleaned to: 'Test' - | - | http://htmlpurifier.org/live/configdoc/plain.html#HTML.ForbiddenElements - | - */ + 'AutoFormat.AutoParagraph' => false, + 'AutoFormat.RemoveEmpty' => false, - 'HTML.ForbiddenElements' => '', + 'Attr.AllowedClasses' => [ + 'h-feed', + 'h-entry', + 'h-cite', + 'h-card', + 'p-author', + 'p-name', + 'p-in-reply-to', + 'p-repost-of', + 'p-comment', + 'u-photo', + 'u-uid', + 'u-url', + 'dt-published', + 'e-content', + 'mention', + 'hashtag', + 'ellipsis', + 'invisible' + ], - /* - |-------------------------------------------------------------------------- - | CSS.AllowedProperties - |-------------------------------------------------------------------------- - | - | The Allowed CSS properties. - | - | http://htmlpurifier.org/live/configdoc/plain.html#CSS.AllowedProperties - | - */ + 'Attr.AllowedRel' => [ + 'noreferrer', + 'noopener', + 'nofollow' + ], - 'CSS.AllowedProperties' => '', + 'HTML.TargetBlank' => true, - /* - |-------------------------------------------------------------------------- - | AutoFormat.AutoParagraph - |-------------------------------------------------------------------------- - | - | The Allowed CSS properties. - | - | This directive turns on auto-paragraphing, where double - | newlines are converted in to paragraphs whenever possible. - | - | http://htmlpurifier.org/live/configdoc/plain.html#AutoFormat.AutoParagraph - | - */ + 'HTML.Nofollow' => true, - 'AutoFormat.AutoParagraph' => false, + 'URI.DefaultScheme' => 'https', - /* - |-------------------------------------------------------------------------- - | AutoFormat.RemoveEmpty - |-------------------------------------------------------------------------- - | - | When enabled, HTML Purifier will attempt to remove empty - | elements that contribute no semantic information to the document. - | - | http://htmlpurifier.org/live/configdoc/plain.html#AutoFormat.RemoveEmpty - | - */ + 'URI.DisableExternalResources' => true, - 'AutoFormat.RemoveEmpty' => false, + 'URI.DisableResources' => true, - 'Attr.AllowedClasses' => [ - 'h-feed', - 'h-entry', - 'h-cite', - 'h-card', - 'p-author', - 'p-name', - 'p-in-reply-to', - 'p-repost-of', - 'p-comment', - 'u-photo', - 'u-uid', - 'u-url', - 'dt-published', - 'e-content', - 'mention', - 'hashtag', - 'ellipsis', - 'invisible' + 'URI.AllowedSchemes' => [ + 'http' => true, + 'https' => true, + ], + + 'URI.HostBlacklist' => config('costar.enabled') ? config('costar.domain.block') : [], ], - 'Attr.AllowedRel' => [ - 'noreferrer', - 'noopener', - 'nofollow' - ], - - 'HTML.TargetBlank' => true, - - 'HTML.Nofollow' => true, - - 'URI.DefaultScheme' => 'https', - - 'URI.DisableExternalResources' => true, - - 'URI.DisableResources' => true, - - 'URI.AllowedSchemes' => [ - 'http' => true, - 'https' => true, - ], - - 'URI.HostBlacklist' => config('costar.enabled') ? config('costar.domain.block') : [], - ], + /* + |-------------------------------------------------------------------------- + | HTMLPurifier definitions + |-------------------------------------------------------------------------- + | + | Here you may specify a class that augments the HTML definitions used by + | HTMLPurifier. Additional HTML5 definitions are provided out of the box. + | When specifying a custom class, make sure it implements the interface: + | + | \Stevebauman\Purify\Definitions\Definition + | + | Note that these definitions are applied to every Purifier instance. + | + | Documentation: http://htmlpurifier.org/docs/enduser-customize.html + | + */ + + 'definitions' => Html5Definition::class, + + /* + |-------------------------------------------------------------------------- + | Serializer + |-------------------------------------------------------------------------- + | + | The storage implementation where HTMLPurifier can store its serializer files. + | If the filesystem cache is in use, the path must be writable through the + | storage disk by the web server, otherwise an exception will be thrown. + | + */ + + 'serializer' => [ + 'driver' => env('CACHE_DRIVER', 'file'), + 'cache' => \Stevebauman\Purify\Cache\CacheDefinitionCache::class, + ], + + // 'serializer' => [ + // 'disk' => env('FILESYSTEM_DISK', 'local'), + // 'path' => 'purify', + // 'cache' => \Stevebauman\Purify\Cache\FilesystemDefinitionCache::class, + // ], + ];