mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 16:53:17 +00:00
commit
e2e1a1b2c3
12 changed files with 112 additions and 30 deletions
|
@ -13,6 +13,10 @@
|
||||||
### Configuration
|
### Configuration
|
||||||
- Enable network timeline by default ([b95aec12](https://github.com/pixelfed/pixelfed/commit/b95aec12))
|
- 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
|
### Added
|
||||||
- Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
|
- Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
|
||||||
- Added StatusMentionService, fixes #3026. ([e5387d67](https://github.com/pixelfed/pixelfed/commit/e5387d67))
|
- 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 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 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 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/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)
|
## [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');
|
$scope = $request->input('scope', 'inbox');
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
|
|
||||||
$dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) {
|
if(config('database.default') == 'pgsql') {
|
||||||
return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid)->groupBy('to_id');
|
$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)->groupBy('to_id');
|
->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);
|
->when($scope === 'requests', function($q, $scope) use($pid) {
|
||||||
})
|
return $q->whereToId($pid)->whereIsHidden(true);
|
||||||
->latest()
|
});
|
||||||
|
} 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)
|
->simplePaginate($limit)
|
||||||
->map(function($dm) use($pid) {
|
->map(function($dm) use($pid) {
|
||||||
$from = $pid == $dm->to_id ? $dm->from_id : $dm->to_id;
|
$from = $pid == $dm->to_id ? $dm->from_id : $dm->to_id;
|
||||||
|
|
|
@ -738,6 +738,10 @@ class PublicApiController extends Controller
|
||||||
$min_id = $request->min_id;
|
$min_id = $request->min_id;
|
||||||
$scope = ['photo', 'photo:album', 'video', 'video:album'];
|
$scope = ['photo', 'photo:album', 'video', 'video:album'];
|
||||||
|
|
||||||
|
if(!$min_id && !$max_id) {
|
||||||
|
$min_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if($profile['locked']) {
|
if($profile['locked']) {
|
||||||
if(!$user) {
|
if(!$user) {
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
|
|
|
@ -46,6 +46,8 @@ class StoryController extends StoryComposeController
|
||||||
$r = new \StdClass;
|
$r = new \StdClass;
|
||||||
$r->id = $s->id;
|
$r->id = $s->id;
|
||||||
$r->profile_id = $s->profile_id;
|
$r->profile_id = $s->profile_id;
|
||||||
|
$r->type = $s->type;
|
||||||
|
$r->path = $s->path;
|
||||||
return $r;
|
return $r;
|
||||||
})
|
})
|
||||||
->unique('profile_id');
|
->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)
|
public static function del($id)
|
||||||
{
|
{
|
||||||
return Cache::forget(self::CACHE_KEY . $id);
|
return Cache::forget(self::CACHE_KEY . $id);
|
||||||
|
|
|
@ -18,26 +18,48 @@ class MediaService
|
||||||
|
|
||||||
public static function get($statusId)
|
public static function get($statusId)
|
||||||
{
|
{
|
||||||
$status = Status::find($statusId);
|
return Cache::remember(self::CACHE_KEY.$statusId, 86400, function() use($statusId) {
|
||||||
if(!$status) {
|
$media = Media::whereStatusId($statusId)->orderBy('order')->get();
|
||||||
return [];
|
if(!$media) {
|
||||||
}
|
|
||||||
$ttl = $status->created_at->lt(now()->subMinutes(30)) ? 129600 : 30;
|
|
||||||
return Cache::remember(self::CACHE_KEY.$statusId, $ttl, function() use($status) {
|
|
||||||
if(!$status) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if(in_array($status->type, ['group:post', 'photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
|
$fractal = new Fractal\Manager();
|
||||||
$media = Media::whereStatusId($status->id)->orderBy('order')->get();
|
$fractal->setSerializer(new ArraySerializer());
|
||||||
$fractal = new Fractal\Manager();
|
$resource = new Fractal\Resource\Collection($media, new MediaTransformer());
|
||||||
$fractal->setSerializer(new ArraySerializer());
|
return $fractal->createData($resource)->toArray();
|
||||||
$resource = new Fractal\Resource\Collection($media, new MediaTransformer());
|
|
||||||
return $fractal->createData($resource)->toArray();
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
public static function del($statusId)
|
||||||
{
|
{
|
||||||
return Cache::forget(self::CACHE_KEY . $statusId);
|
return Cache::forget(self::CACHE_KEY . $statusId);
|
||||||
|
|
|
@ -71,6 +71,7 @@ class StatusService
|
||||||
$status['account']['note_text'],
|
$status['account']['note_text'],
|
||||||
$status['account']['pronouns'],
|
$status['account']['pronouns'],
|
||||||
$status['account']['website'],
|
$status['account']['website'],
|
||||||
|
$status['media_attachments'],
|
||||||
);
|
);
|
||||||
$status['account']['avatar_static'] = $status['account']['avatar'];
|
$status['account']['avatar_static'] = $status['account']['avatar'];
|
||||||
$status['account']['bot'] = false;
|
$status['account']['bot'] = false;
|
||||||
|
@ -80,6 +81,8 @@ class StatusService
|
||||||
$status['account']['header_static'] = url('/storage/headers/missing.png');
|
$status['account']['header_static'] = url('/storage/headers/missing.png');
|
||||||
$status['account']['last_status_at'] = null;
|
$status['account']['last_status_at'] = null;
|
||||||
|
|
||||||
|
$status['media_attachments'] = array_values(MediaService::getMastodon($status['id']));
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
'acct' => $acct,
|
'acct' => $acct,
|
||||||
'display_name' => $profile->name,
|
'display_name' => $profile->name,
|
||||||
'locked' => (bool) $profile->is_private,
|
'locked' => (bool) $profile->is_private,
|
||||||
'followers_count' => $profile->followerCount(),
|
'followers_count' => (int) $profile->followerCount(),
|
||||||
'following_count' => $profile->followingCount(),
|
'following_count' => (int) $profile->followingCount(),
|
||||||
'statuses_count' => (int) $profile->statusCount(),
|
'statuses_count' => (int) $profile->statusCount(),
|
||||||
'note' => $profile->bio ?? '',
|
'note' => $profile->bio ?? '',
|
||||||
'note_text' => strip_tags($profile->bio),
|
'note_text' => strip_tags($profile->bio),
|
||||||
|
|
|
@ -24,8 +24,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
'url' => $profile->url(),
|
'url' => $profile->url(),
|
||||||
'avatar' => $profile->avatarUrl(),
|
'avatar' => $profile->avatarUrl(),
|
||||||
'avatar_static' => $profile->avatarUrl(),
|
'avatar_static' => $profile->avatarUrl(),
|
||||||
'header' => '',
|
'header' => url('/storage/headers/missing.png'),
|
||||||
'header_static' => '',
|
'header_static' => url('/storage/headers/missing.png'),
|
||||||
'followers_count' => (int) $profile->followerCount(),
|
'followers_count' => (int) $profile->followerCount(),
|
||||||
'following_count' => (int) $profile->followingCount(),
|
'following_count' => (int) $profile->followingCount(),
|
||||||
'statuses_count' => (int) $profile->statusCount(),
|
'statuses_count' => (int) $profile->statusCount(),
|
||||||
|
|
3
storage/app/public/.gitignore
vendored
3
storage/app/public/.gitignore
vendored
|
@ -2,4 +2,5 @@
|
||||||
!.gitignore
|
!.gitignore
|
||||||
!no-preview.png
|
!no-preview.png
|
||||||
!m/
|
!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