Commit Graph

601 Commits (784e4eec6ae57a856c5d2de61e95962d9108eb6d)

Author SHA1 Message Date
Shlee 140221fe90
Merge pull request #7192 from pixelfed/refactor/str-of-to-native
Laravel 13 Prep: Replace Str::of() fluent chains with static Str::/native calls
2 weeks ago
Your Name a424493420 Replace Str::of() fluent chains with static Str::/native calls
Aligns with the app's dominant convention (171 static Str:: calls vs
24 Str::of() chains). Uses Str::afterLast() for the repeated
"segment after last slash" pattern, Str::matchAll() where a
Collection return is needed, and native explode()/substr() where a
plain array/string suffices.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 weeks ago
Your Name 277b8aa970 Use now() helper instead of Carbon::now() for current-time access
Aligns with the app's dominant convention (413 now()/today() call
sites vs 12 Carbon::now()). Carbon::parse() calls are untouched since
they parse arbitrary date strings, not current-time access.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 weeks ago
Daniel Supernault 7975ba9c75
Fix StoryCarousel cache invalidation 2 weeks ago
Your Name 73fb5ed696 Fall back to stored profile when remote refresh fails 3 weeks ago
Your Name 1905da723d Validate publicKey.id host on inbox actor ingest to prevent key_id poisoning 3 weeks ago
Daniel Supernault c558724e47
Update AP Helpers 3 weeks ago
Daniel Supernault e57f7ccd3a
Update Helpers.php 3 weeks ago
Shlee b62eafd054
Update UpdatePersonValidator.php 3 weeks ago
Your Name 042ab0a6e4 Convert optional() to nullsafe operator
Applies patch 2/21 from pixelfed-staging PR #9: replaces optional($x)->y
with $x?->y across 16 files. Pint-clean.
4 weeks ago
Shlee 7cf6e77148
Update Localization.php 4 weeks ago
Your Name 0df4c7117d Add domain-mismatch metadata to Announce status fetch and stop noisy ERROR logs
storeStatus() now throws with JSON metadata (checked id/url hosts, expected
rule, and the full activity payload) when status domains mismatch. The Announce
inbox handler catches this, logs the context at debug level, and returns
gracefully instead of surfacing a full production ERROR stack trace.
4 weeks ago
Your Name b6d645a4d4 fix: delete superseded image/thumbnail files instead of orphaning them
Image::handleImageTransform derives the output filename from the current
media_path and applies the encoder's output extension. When that differs from
what is already stored (heic/avif -> jpg, or a thumbnail regenerated to a new
extension), the new file landed at a different path and the previous file was
left orphaned in the media directory — the source of the leftover _thumb files
under public/m/_v2.

Capture the path each transform supersedes and delete it after a successful
write (only when the new output path differs, so we never delete what we just
wrote). Remove the stale MediaDeleteLeafCleanupTest whose source change is not
in the tree.
4 weeks ago
Your Name 87ed60d675 Accept compacted Note attachments (#6588)
Normalize JSON-LD compacted single attachments (a bare object instead of a
one-item array) in getAttachments(), and route verifyAttachments() through it
so validation and import share one normalization path.

Includes PR #6589's tests plus additional edge-case coverage: list-form
preservation, bare-input normalization, and guards for missing/empty/scalar
attachments.
4 weeks ago
Shlee 79af98f9d0
Merge pull request #6667 from vinzgreg/fix/blurhash-memory-strands-video-uploads
Fix videos never reaching cloud storage by downscaling in Blurhash (#2652)
4 weeks ago
Your Name 0d01d5a963 Fix duplicate-key violation when importing remote media attachments
Helpers::importNoteAttachment unconditionally inserted a new Media row per
attachment, so re-importing a remote status (an Announce racing another
inbox job, a re-fetch, or a duplicate url within one activity) hit the
media_status_id_media_path_unique constraint and crashed the queue job with
a 1062 UniqueConstraintViolationException, dropping the boost/import.

Make createMediaAttachment idempotent on (status_id, media_path): skip when
a row already exists, and catch the unique-constraint violation as a
lost-race no-op, returning null so the caller skips re-dispatching storage.

Adds regression tests (re-import no-op, distinct urls still stored,
concurrent-insert returns null).
4 weeks ago
Your Name 3d82a8e8b2 Fix unauthenticated SSRF in remote media/avatar fetch (variant of CVE-2026-71246)
The remote media path validated URLs only as strings (Helpers::validateUrl
normalizes the host + checks a ban list) and then downloaded them with
Http::head + file_get_contents($url), which resolve DNS themselves and
follow redirects with no private-IP checks and no address pinning. A remote
actor whose icon.url redirected to an internal address (e.g. 172.18.0.1 or
169.254.169.254) made the queue worker fetch internal content and, for
image responses, republish it at a public avatar URL. No account required.

Fixes:
- Add SecureMediaFetchService: validates URL, resolves + rejects non-global
  IPs (fail-closed), pins the connection to the validated IP via
  CURLOPT_RESOLVE, disables auto-redirects with per-hop re-validation, and
  enforces https-only + a byte cap. Mirrors the ActivityPubFetchService
  hardening from CVE-2026-71246.
- Route MediaStorageService head()/fetchAvatar()/remoteToCloud() through it,
  removing the bare Http::head and file_get_contents($url) sinks.
- validateUrl(): when DNS verification is enabled, reject hosts that resolve
  into reserved ranges, closing the metadata.google.internal bypass.
- Harden adjacent same-class sinks: CustomEmojiService (emoji doc + image +
  head), FetchCacheService/webfinger, and DiscoverActor.
- Add regression tests (tests/Unit/ActivityPub/SsrfUrlValidationTest.php).
4 weeks ago
Your Name 941c305104 fix: resolve larastan class.notFound errors
- Add missing FractalService import to Groups/GroupCommentService and
  Groups/GroupPostService (wrong namespace resolution)
- Update Inbox handler traits to use App\Models\* namespace instead of
  old App\* references (Status, Profile, DirectMessage, Media, Follower,
  Like, Instance, Story, User, FollowRequest, Notification, UserFilter,
  StoryView)
- Update HttpClientMigrationTest to use App\Models\* namespace
1 month ago
Your Name e7b70c6084 refactor: extract duplicate patterns into shared methods
1. Add FractalService with static item() and collection() helpers
   replacing 22 call sites that repeated the 4-line Fractal Manager
   + ArraySerializer boilerplate.

2. Add AccountInterstitial::createFromStatus() factory method
   consolidating 4 identical 15-line blocks that create interstitials
   with status metadata.

3. Add NotificationService::createNotification() to handle the
   repeated pattern of creating, caching, and registering a
   notification in the recipient's feed.

4. Add NotificationService::firstOrCreateNotification() for
   idempotent notifications (share/boost, mention) that should
   only notify once per actor+action+item combination.
1 month ago
Shlee a1b3d2463d
Merge branch 'staging' into refactor/split-inbox-handlers 1 month ago
Your Name f4b6d03ae6 refactor: split ActivityPub Inbox into focused traits with shared helpers
- Extract InboxHelpers trait with common utilities (domain/user blocking, actor validation, notification deletion, cache clearing)
- Create domain-specific handler traits: HandlesFollows, HandlesLikes, HandlesCreates, HandlesAnnouncements, HandlesDeletes, HandlesUndos, HandlesStories, HandlesFlags, HandlesUpdates, HandlesMoves
- Merge duplicate story reaction/reply handlers into single handleStoryInteraction method
- Break handleDirectMessage into focused sub-methods
- Reduce Inbox.php to thin verb router (~167 lines)
- No behavioral changes; public API preserved
1 month ago
Your Name c0cde2f682 refactor: move 52 legacy models from App\ to App\Models\
Move all Eloquent models from the app/ root directory to app/Models/
for consistency with modern Laravel conventions. The project already had
54 models in App\Models; this migrates the remaining 52 legacy models.

Changes:
- Move 52 model files from app/ to app/Models/
- Update namespace declarations in each model
- Update all ~1000 import references across the codebase
- Add Relation::morphMap() in AppServiceProvider for backward
  compatibility with existing polymorphic database records
- Add missing HasSnowflakePrimary imports for models that relied
  on same-namespace resolution
1 month ago
Your Name 2b1c9c818b polish 1 month ago
Daniel Supernault 33dce75f2c
Pint app/ 1 month ago
Your Name 49b85e9f22 fix: use query methods instead of collection methods (phpstan noUnnecessaryCollectionCall)
- PollService: pluck()->first() → value()
- StoryService: groupBy()->pluck()->count() → distinct()->count()
- Inbox: find($objects)->count() → whereIn('id', $objects)->count()
1 month ago
Shlee 899e360b48
Update Extractor.php 1 month ago
Your Name c807a8524c refactor: replace short facade aliases with fully-qualified imports
Convert all 273 short facade alias imports (e.g. 'use Cache;') to their
fully-qualified class names (e.g. 'use Illuminate\Support\Facades\Cache;')
across 193 files.

This resolves 643 PHPStan 'class.notFound' errors caused by the static
analyzer being unable to resolve global aliases, and aligns with modern
Laravel conventions. It also unblocks removing the aliases array from
config/app.php in a future change.

All 107 tests pass.
1 month ago
Your Name edb4368b08 refactor: replace deprecated laravel/helpers with native alternatives
Replace all deprecated helper function calls:
- str_slug() → Str::slug()
- starts_with() → str_starts_with()
- ends_with() → str_ends_with()
- array_first() → Arr::first()
- array_last() → Arr::last()
- array_flatten() → Arr::flatten()

Remove laravel/helpers package from composer.json as it is no longer
needed and will not be maintained for Laravel 13.
1 month ago
Ashley Hull ab07a705e6
Merge branch 'dev' into shift-179490 1 month ago
Shlee 2e97341e0d
Merge branch 'staging' into fix/exif-orientation-portrait-photos 1 month ago
Your Name 552a55c2d2 Upgrade images to v4 1 month ago
Daniel Supernault 30085e8708
Fix validateUrl() 1 month ago
Daniel Supernault ce64d0961d
Update Inbox, fixes #6784 1 month ago
Shift 19880c2ffb
Convert string references to `::class`
PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
1 month ago
dansup ec38262338
Merge pull request #6576 from shleeable/covidremove
Clean up Covid/WHO
1 month ago
Daniel Supernault bb33409fea
Lint 1 month ago
Daniel Supernault b84ae82f60
Update helpers 1 month ago
dansup a5aba15752
Merge pull request #6674 from pixelfed/shleeable-patch-7
Fix: Update type on handleDirectMessage
1 month ago
dansup 6170ff1fe0
Merge pull request #6681 from pixelfed/shleeable-patch-16
ActivityPub migration allows exceeding MAX_FOLLOWING and can silently drop follows during move window
1 month ago
dansup 4748f66a02
Merge pull request #6687 from pixelfed/shleeable-patch-21
Improve validation
1 month ago
Daniel Supernault 2216402ed4
Update Helpers 1 month ago
Shlee 595220e088
Update Helpers.php 2 months ago
Shlee acd509e0a3
Update Inbox.php 2 months ago
Shlee 886306d1d0
Update Helpers.php 2 months ago
Shlee 9d5e2d4f1f
Update Inbox.php 2 months ago
vinz ef56880a74 Fix videos never reaching cloud storage by downscaling in Blurhash
Blurhash::generate() allocates one PHP array per pixel of the source. At
roughly 255 bytes per pixel (measured: 224 MB peak for a 720x1280 frame) a
1920x1080 frame approaches half a gigabyte.

Image thumbnails survive this because they are capped at 640x640 in
Image::__construct() *and* run under that constructor's
ini_set('memory_limit', '1024M'). Video thumbnails get neither: FFmpeg saves
them at the source video's resolution, and VideoThumbnail never raises the
limit. So a video whose frame is 1080p or larger exhausts memory_limit.

That is a PHP fatal, not an \Exception, which has three consequences:

  - the catch block in VideoThumbnail::handle() does not catch it
  - the job never lands in failed_jobs, so nothing reports a problem
  - MediaStoragePipeline::dispatch() on the last line of handle() never runs

The video therefore stays on local disk permanently while images beside it
replicate normally. Reported in #2652 (2021-02-13) and diagnosed correctly in
that thread on 2021-11-04.

Two changes:

1. Blurhash::generate() downscales to 128px on the long edge before sampling.
   The result is a 4x4-component DCT, so full-resolution sampling adds
   essentially nothing: measured against the full-resolution hash, mean
   per-channel deviation of the decoded 24x24 preview is ~7.5/255 at a 32px
   sample, ~4.5/255 at 64px, ~2.5/255 at 128px, and no better at 256px. Peak
   memory for the frame above drops from 224 MB to 6 MB.

   This removes the ceiling for every caller rather than moving it, which is
   all that raising memory_limit would have done. Existing stored hashes are
   not recomputed, so nothing already published changes appearance.

2. VideoThumbnail wraps the blurhash in its own try/catch, so a decorative
   step can no longer skip the replication dispatch. Change 1 covers the
   fatal; this covers any ordinary exception.

Verified on a live instance with S3 cloud storage: a 1920x1080 video that
previously stranded now generates a blurhash, uploads original and thumbnail
to the bucket, sets cdn_url/thumbnail_url/replicated_at, and removes the local
copies. Existing images re-hash to visually identical previews.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 months ago
Stefan 4f13ebfe3f fix: apply EXIF orientation before resizing portrait images
Smartphone photos stored in landscape orientation with an EXIF rotation
tag were being saved to S3 in the wrong orientation. Image.php read the
raw pixel dimensions without first applying the EXIF tag, so portrait
photos (e.g. 4032×3024 with Orientation=6) were classified and resized
as landscape (1920×1080).

Calling orient() immediately after read() physically rotates the image
to match its EXIF orientation tag before any dimension checks or
scaling. This ensures portrait photos remain portrait after processing.

Intervention Image v3 reference:
https://image.intervention.io/v3/modifying/orientation
4 months ago
Your Name 41089fcccd Remove COVID label feature flag and related code
Remove ENABLE_COVID_LABEL, COVID_LABEL_URL, and COVID_LABEL_ORG env
vars and all associated backend/frontend code:

- config/instance.php: remove label.covid config block
- StatusLabelService: remove keyword matching, return static false
- Site/Config.php: remove label.covid from API response
- StatusCard.vue: remove COVID banner and labelRedirect method
- GroupStatus.vue: remove COVID banner and labelRedirect method
- diagnostics blade: remove COVID diagnostic rows
5 months ago
Daniel Supernault 78a657d7df
Refactor, use actor private key, thanks Mastodon ;) 6 months ago
Daniel Supernault c5868de7d6
Lint 6 months ago