mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
commit
4bac21d5d5
6 changed files with 64 additions and 3 deletions
|
@ -470,7 +470,7 @@ class ApiV1Dot1Controller extends Controller
|
|||
abort_if(BouncerService::checkIp($request->ip()), 404);
|
||||
}
|
||||
|
||||
$rl = RateLimiter::attempt('pf:apiv1.1:iar:'.$request->ip(), 3, function(){}, 1800);
|
||||
$rl = RateLimiter::attempt('pf:apiv1.1:iar:'.$request->ip(), config('pixelfed.app_registration_rate_limit_attempts', 3), function(){}, config('pixelfed.app_registration_rate_limit_decay', 1800));
|
||||
abort_if(!$rl, 400, 'Too many requests');
|
||||
|
||||
$this->validate($request, [
|
||||
|
|
|
@ -286,4 +286,7 @@ return [
|
|||
'max_altext_length' => env('PF_MEDIA_MAX_ALTTEXT_LENGTH', 1000),
|
||||
|
||||
'allow_app_registration' => env('PF_ALLOW_APP_REGISTRATION', true),
|
||||
|
||||
'app_registration_rate_limit_attempts' => env('PF_IAR_RL_ATTEMPTS', 3),
|
||||
'app_registration_rate_limit_decay' => env('PF_IAR_RL_DECAY', 1800),
|
||||
];
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
v-on:bookmark="handleBookmark()"
|
||||
v-on:share="shareStatus()"
|
||||
v-on:unshare="unshareStatus()"
|
||||
v-on:follow="follow()"
|
||||
v-on:unfollow="unfollow()"
|
||||
v-on:counter-change="counterChange"
|
||||
/>
|
||||
</div>
|
||||
|
@ -333,6 +335,30 @@
|
|||
})
|
||||
},
|
||||
|
||||
follow() {
|
||||
axios.post('/api/v1/accounts/' + this.post.account.id + '/follow')
|
||||
.then(res => {
|
||||
this.$store.commit('updateRelationship', [res.data]);
|
||||
this.user.following_count++;
|
||||
this.post.account.followers_count++;
|
||||
}).catch(err => {
|
||||
swal('Oops!', 'An error occurred when attempting to follow this account.', 'error');
|
||||
this.post.relationship.following = false;
|
||||
});
|
||||
},
|
||||
|
||||
unfollow() {
|
||||
axios.post('/api/v1/accounts/' + this.post.account.id + '/unfollow')
|
||||
.then(res => {
|
||||
this.$store.commit('updateRelationship', [res.data]);
|
||||
this.user.following_count--;
|
||||
this.post.account.followers_count--;
|
||||
}).catch(err => {
|
||||
swal('Oops!', 'An error occurred when attempting to unfollow this account.', 'error');
|
||||
this.post.relationship.following = true;
|
||||
});
|
||||
},
|
||||
|
||||
openContextMenu() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.contextMenu.open();
|
||||
|
|
|
@ -205,12 +205,20 @@
|
|||
|
||||
<div v-else class="float-right">
|
||||
<button
|
||||
v-if="posts.length > 0"
|
||||
type="button"
|
||||
class="btn btn-outline-primary btn-sm py-1 font-weight-bold px-3"
|
||||
@click.prevent="publishCollection">
|
||||
Publish
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn btn-outline-primary btn-sm py-1 font-weight-bold px-3 disabled" disabled>
|
||||
Publish
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm py-1 font-weight-bold px-3"
|
||||
|
@ -527,6 +535,11 @@ export default {
|
|||
},
|
||||
|
||||
publishCollection() {
|
||||
if (this.posts.length === 0) {
|
||||
swal('Error', 'You cannot publish an empty collection');
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.owner == false) {
|
||||
return;
|
||||
}
|
||||
|
@ -541,6 +554,8 @@ export default {
|
|||
.then(res => {
|
||||
console.log(res.data);
|
||||
// window.location.href = res.data.url;
|
||||
}).catch(err => {
|
||||
swal('Something went wrong', 'There was a problem with your request, please try again later.', 'error')
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
|
|
|
@ -1084,6 +1084,16 @@ export default {
|
|||
return App.util.format.timeAgo(ts);
|
||||
},
|
||||
|
||||
formatBytes(bytes, decimals = 2) {
|
||||
if (!+bytes) {
|
||||
return '0 Bytes'
|
||||
}
|
||||
const dec = decimals < 0 ? 0 : decimals
|
||||
const units = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
const quotient = Math.floor(Math.log(bytes) / Math.log(1024))
|
||||
return `${parseFloat((bytes / Math.pow(1024, quotient)).toFixed(dec))} ${units[quotient]}`
|
||||
},
|
||||
|
||||
fetchProfile() {
|
||||
let tags = {
|
||||
public: 'Public',
|
||||
|
@ -1194,6 +1204,13 @@ export default {
|
|||
}, 300);
|
||||
}).catch(function(e) {
|
||||
switch(e.response.status) {
|
||||
case 413:
|
||||
self.uploading = false;
|
||||
io.value = null;
|
||||
swal('File is too large', 'The file you uploaded has the size of ' + self.formatBytes(io.size) + '. Unfortunately, only images up to ' + self.formatBytes(self.config.uploader.max_photo_size * 1024) + ' are supported.\nPlease resize the file and try again.', 'error');
|
||||
self.page = 2;
|
||||
break;
|
||||
|
||||
case 451:
|
||||
self.uploading = false;
|
||||
io.value = null;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
@endsection
|
||||
|
||||
@push('meta')<meta property="og:description" content="{{$profile->bio}}">
|
||||
@push('meta')<meta property="og:description" content="{{strip_tags($profile->bio)}}">
|
||||
@if(false == $settings['crawlable'] || $profile->remote_url)
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
@else <meta property="og:image" content="{{$profile->avatarUrl()}}">
|
||||
|
|
Loading…
Reference in a new issue