mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 13:33:18 +00:00
commit
443f20eaa6
5 changed files with 38 additions and 14 deletions
|
@ -4,6 +4,7 @@
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Stories on postgres instances ([5ffa71da](https://github.com/pixelfed/pixelfed/commit/5ffa71da))
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- Updated StatusController, restrict edits to 24 hours ([ae24433b](https://github.com/pixelfed/pixelfed/commit/ae24433b))
|
- Updated StatusController, restrict edits to 24 hours ([ae24433b](https://github.com/pixelfed/pixelfed/commit/ae24433b))
|
||||||
|
|
|
@ -53,6 +53,11 @@ class RegisterController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function validator(array $data)
|
protected function validator(array $data)
|
||||||
{
|
{
|
||||||
|
if(config('database.default') == 'pgsql') {
|
||||||
|
$data['username'] = strtolower($data['username']);
|
||||||
|
$data['email'] = strtolower($data['email']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->validateUsername($data['username']);
|
$this->validateUsername($data['username']);
|
||||||
$this->validateEmail($data['email']);
|
$this->validateEmail($data['email']);
|
||||||
|
|
||||||
|
@ -105,6 +110,11 @@ class RegisterController extends Controller
|
||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
{
|
{
|
||||||
|
if(config('database.default') == 'pgsql') {
|
||||||
|
$data['username'] = strtolower($data['username']);
|
||||||
|
$data['email'] = strtolower($data['email']);
|
||||||
|
}
|
||||||
|
|
||||||
return User::create([
|
return User::create([
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'username' => $data['username'],
|
'username' => $data['username'],
|
||||||
|
|
|
@ -22,6 +22,10 @@ class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
public function show(Request $request, $username)
|
public function show(Request $request, $username)
|
||||||
{
|
{
|
||||||
|
if(config('database.default') == 'pgsql') {
|
||||||
|
$username = strtolower($username);
|
||||||
|
}
|
||||||
|
|
||||||
$user = Profile::whereNull('domain')
|
$user = Profile::whereNull('domain')
|
||||||
->whereNull('status')
|
->whereNull('status')
|
||||||
->whereUsername($username)
|
->whereUsername($username)
|
||||||
|
|
|
@ -108,16 +108,25 @@ class StoryController extends Controller
|
||||||
|
|
||||||
$profile = $request->user()->profile;
|
$profile = $request->user()->profile;
|
||||||
$following = $profile->following->pluck('id')->toArray();
|
$following = $profile->following->pluck('id')->toArray();
|
||||||
$groupBy = config('database.default') == 'pgsql' ? 'id' : 'profile_id';
|
|
||||||
|
|
||||||
$stories = Story::with('profile')
|
if(config('database.default') == 'pgsql') {
|
||||||
->groupBy($groupBy)
|
$db = Story::with('profile')
|
||||||
->whereIn('profile_id', $following)
|
->whereIn('profile_id', $following)
|
||||||
->where('expires_at', '>', now())
|
->where('expires_at', '>', now())
|
||||||
->orderByDesc('expires_at')
|
->distinct('profile_id')
|
||||||
->take(9)
|
->take(9)
|
||||||
->get()
|
->get();
|
||||||
->map(function($s, $k) {
|
} else {
|
||||||
|
$db = Story::with('profile')
|
||||||
|
->whereIn('profile_id', $following)
|
||||||
|
->where('expires_at', '>', now())
|
||||||
|
->orderByDesc('expires_at')
|
||||||
|
->groupBy('profile_id')
|
||||||
|
->take(9)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$stories = $db->map(function($s, $k) {
|
||||||
return [
|
return [
|
||||||
'id' => (string) $s->id,
|
'id' => (string) $s->id,
|
||||||
'photo' => $s->profile->avatarUrl(),
|
'photo' => $s->profile->avatarUrl(),
|
||||||
|
|
|
@ -412,14 +412,14 @@ class Helpers {
|
||||||
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
||||||
if(!$profile) {
|
if(!$profile) {
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
$profile->domain = $domain;
|
$profile->domain = strtolower($domain);
|
||||||
$profile->username = (string) Purify::clean($remoteUsername);
|
$profile->username = strtolower(Purify::clean($remoteUsername));
|
||||||
$profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
$profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
||||||
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
||||||
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
||||||
$profile->inbox_url = $res['inbox'];
|
$profile->inbox_url = strtolower($res['inbox']);
|
||||||
$profile->outbox_url = $res['outbox'];
|
$profile->outbox_url = strtolower($res['outbox']);
|
||||||
$profile->remote_url = $res['id'];
|
$profile->remote_url = strtolower($res['id']);
|
||||||
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
||||||
$profile->key_id = $res['publicKey']['id'];
|
$profile->key_id = $res['publicKey']['id'];
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
|
Loading…
Reference in a new issue