mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 08:44:49 +00:00
commit
e2e1a1b2c3
12 changed files with 112 additions and 30 deletions
|
@ -13,6 +13,10 @@
|
|||
### Configuration
|
||||
- Enable network timeline by default ([b95aec12](https://github.com/pixelfed/pixelfed/commit/b95aec12))
|
||||
|
||||
### Postgres Compatibility
|
||||
- Fix Story recent endpoint on postgres instances ([ddf41dc3](https://github.com/pixelfed/pixelfed/commit/ddf41dc3))
|
||||
- Fix Direct Message conversations endpoint on postgres instances ([fcabc9be](https://github.com/pixelfed/pixelfed/commit/fcabc9be))
|
||||
|
||||
### Added
|
||||
- Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
|
||||
- Added StatusMentionService, fixes #3026. ([e5387d67](https://github.com/pixelfed/pixelfed/commit/e5387d67))
|
||||
|
@ -80,6 +84,7 @@
|
|||
- Updated AccountService, fix json casting. ([e5f8f344](https://github.com/pixelfed/pixelfed/commit/e5f8f344))
|
||||
- Updated ApiV1Controller, fix illegal operator bug by setting default min_id. ([415826f2](https://github.com/pixelfed/pixelfed/commit/415826f2))
|
||||
- Updated StatusService, add getMastodon method for mastoapi compatibility. ([36a129fe](https://github.com/pixelfed/pixelfed/commit/36a129fe))
|
||||
- Updated PublicApiController, fix accountStatuses pagination operator. ([85fc9dd0](https://github.com/pixelfed/pixelfed/commit/85fc9dd0))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)
|
||||
|
|
|
@ -1701,16 +1701,29 @@ class ApiV1Controller extends Controller
|
|||
$scope = $request->input('scope', 'inbox');
|
||||
$pid = $request->user()->profile_id;
|
||||
|
||||
$dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) {
|
||||
return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid)->groupBy('to_id');
|
||||
})
|
||||
->when($scope === 'sent', function($q, $scope) use($pid) {
|
||||
return $q->whereFromId($pid)->groupBy('to_id');
|
||||
})
|
||||
->when($scope === 'requests', function($q, $scope) use($pid) {
|
||||
return $q->whereToId($pid)->whereIsHidden(true);
|
||||
})
|
||||
->latest()
|
||||
if(config('database.default') == 'pgsql') {
|
||||
$dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) {
|
||||
return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid);
|
||||
})
|
||||
->when($scope === 'sent', function($q, $scope) use($pid) {
|
||||
return $q->whereFromId($pid);
|
||||
})
|
||||
->when($scope === 'requests', function($q, $scope) use($pid) {
|
||||
return $q->whereToId($pid)->whereIsHidden(true);
|
||||
});
|
||||
} else {
|
||||
$dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) {
|
||||
return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid)->groupBy('to_id');
|
||||
})
|
||||
->when($scope === 'sent', function($q, $scope) use($pid) {
|
||||
return $q->whereFromId($pid)->groupBy('to_id');
|
||||
})
|
||||
->when($scope === 'requests', function($q, $scope) use($pid) {
|
||||
return $q->whereToId($pid)->whereIsHidden(true);
|
||||
});
|
||||
}
|
||||
|
||||
$dms = $dms->latest()
|
||||
->simplePaginate($limit)
|
||||
->map(function($dm) use($pid) {
|
||||
$from = $pid == $dm->to_id ? $dm->from_id : $dm->to_id;
|
||||
|
|
|
@ -738,6 +738,10 @@ class PublicApiController extends Controller
|
|||
$min_id = $request->min_id;
|
||||
$scope = ['photo', 'photo:album', 'video', 'video:album'];
|
||||
|
||||
if(!$min_id && !$max_id) {
|
||||
$min_id = 1;
|
||||
}
|
||||
|
||||
if($profile['locked']) {
|
||||
if(!$user) {
|
||||
return response()->json([]);
|
||||
|
|
|
@ -46,6 +46,8 @@ class StoryController extends StoryComposeController
|
|||
$r = new \StdClass;
|
||||
$r->id = $s->id;
|
||||
$r->profile_id = $s->profile_id;
|
||||
$r->type = $s->type;
|
||||
$r->path = $s->path;
|
||||
return $r;
|
||||
})
|
||||
->unique('profile_id');
|
||||
|
|
|
@ -33,6 +33,35 @@ class AccountService
|
|||
});
|
||||
}
|
||||
|
||||
public static function getMastodon($id, $softFail = false)
|
||||
{
|
||||
$account = self::get($id, $softFail);
|
||||
if(!$account) {
|
||||
return null;
|
||||
}
|
||||
|
||||
unset(
|
||||
$account['header_bg'],
|
||||
$account['is_admin'],
|
||||
$account['last_fetched_at'],
|
||||
$account['local'],
|
||||
$account['location'],
|
||||
$account['note_text'],
|
||||
$account['pronouns'],
|
||||
$account['website']
|
||||
);
|
||||
|
||||
$account['avatar_static'] = $account['avatar'];
|
||||
$account['bot'] = false;
|
||||
$account['emojis'] = [];
|
||||
$account['fields'] = [];
|
||||
$account['header'] = url('/storage/headers/missing.png');
|
||||
$account['header_static'] = url('/storage/headers/missing.png');
|
||||
$account['last_status_at'] = null;
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
public static function del($id)
|
||||
{
|
||||
return Cache::forget(self::CACHE_KEY . $id);
|
||||
|
|
|
@ -18,26 +18,48 @@ class MediaService
|
|||
|
||||
public static function get($statusId)
|
||||
{
|
||||
$status = Status::find($statusId);
|
||||
if(!$status) {
|
||||
return [];
|
||||
}
|
||||
$ttl = $status->created_at->lt(now()->subMinutes(30)) ? 129600 : 30;
|
||||
return Cache::remember(self::CACHE_KEY.$statusId, $ttl, function() use($status) {
|
||||
if(!$status) {
|
||||
return Cache::remember(self::CACHE_KEY.$statusId, 86400, function() use($statusId) {
|
||||
$media = Media::whereStatusId($statusId)->orderBy('order')->get();
|
||||
if(!$media) {
|
||||
return [];
|
||||
}
|
||||
if(in_array($status->type, ['group:post', 'photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
|
||||
$media = Media::whereStatusId($status->id)->orderBy('order')->get();
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Collection($media, new MediaTransformer());
|
||||
return $fractal->createData($resource)->toArray();
|
||||
}
|
||||
return [];
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Collection($media, new MediaTransformer());
|
||||
return $fractal->createData($resource)->toArray();
|
||||
});
|
||||
}
|
||||
|
||||
public static function getMastodon($id)
|
||||
{
|
||||
$media = self::get($id);
|
||||
if(!$media) {
|
||||
return [];
|
||||
}
|
||||
$medias = collect($media)
|
||||
->map(function($media) {
|
||||
$mime = $media['mime'] ? explode('/', $media['mime']) : false;
|
||||
unset(
|
||||
$media['optimized_url'],
|
||||
$media['license'],
|
||||
$media['is_nsfw'],
|
||||
$media['orientation'],
|
||||
$media['filter_name'],
|
||||
$media['filter_class'],
|
||||
$media['mime']
|
||||
);
|
||||
|
||||
$media['type'] = $mime ? strtolower($mime[0]) : 'unknown';
|
||||
return $media;
|
||||
})
|
||||
->filter(function($m) {
|
||||
return $m && isset($m['url']);
|
||||
})
|
||||
->values();
|
||||
|
||||
return $medias->toArray();
|
||||
}
|
||||
|
||||
public static function del($statusId)
|
||||
{
|
||||
return Cache::forget(self::CACHE_KEY . $statusId);
|
||||
|
|
|
@ -71,6 +71,7 @@ class StatusService
|
|||
$status['account']['note_text'],
|
||||
$status['account']['pronouns'],
|
||||
$status['account']['website'],
|
||||
$status['media_attachments'],
|
||||
);
|
||||
$status['account']['avatar_static'] = $status['account']['avatar'];
|
||||
$status['account']['bot'] = false;
|
||||
|
@ -80,6 +81,8 @@ class StatusService
|
|||
$status['account']['header_static'] = url('/storage/headers/missing.png');
|
||||
$status['account']['last_status_at'] = null;
|
||||
|
||||
$status['media_attachments'] = array_values(MediaService::getMastodon($status['id']));
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
|||
'acct' => $acct,
|
||||
'display_name' => $profile->name,
|
||||
'locked' => (bool) $profile->is_private,
|
||||
'followers_count' => $profile->followerCount(),
|
||||
'following_count' => $profile->followingCount(),
|
||||
'followers_count' => (int) $profile->followerCount(),
|
||||
'following_count' => (int) $profile->followingCount(),
|
||||
'statuses_count' => (int) $profile->statusCount(),
|
||||
'note' => $profile->bio ?? '',
|
||||
'note_text' => strip_tags($profile->bio),
|
||||
|
|
|
@ -24,8 +24,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
|||
'url' => $profile->url(),
|
||||
'avatar' => $profile->avatarUrl(),
|
||||
'avatar_static' => $profile->avatarUrl(),
|
||||
'header' => '',
|
||||
'header_static' => '',
|
||||
'header' => url('/storage/headers/missing.png'),
|
||||
'header_static' => url('/storage/headers/missing.png'),
|
||||
'followers_count' => (int) $profile->followerCount(),
|
||||
'following_count' => (int) $profile->followingCount(),
|
||||
'statuses_count' => (int) $profile->statusCount(),
|
||||
|
|
3
storage/app/public/.gitignore
vendored
3
storage/app/public/.gitignore
vendored
|
@ -2,4 +2,5 @@
|
|||
!.gitignore
|
||||
!no-preview.png
|
||||
!m/
|
||||
!textimg/
|
||||
!textimg/
|
||||
!headers/
|
||||
|
|
3
storage/app/public/headers/.gitignore
vendored
Normal file
3
storage/app/public/headers/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!.gitignore
|
||||
!missing.png
|
BIN
storage/app/public/headers/missing.png
Normal file
BIN
storage/app/public/headers/missing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 B |
Loading…
Reference in a new issue