mirror of
https://github.com/misskey-dev/misskey
synced 2024-11-28 14:58:36 +09:00
Make max allowed text length configurable (#2992)
* Make max allowed text length configurable * Fix canPost
This commit is contained in:
parent
f24d202024
commit
daa22d68fa
@ -164,3 +164,6 @@ drive:
|
|||||||
# external: true
|
# external: true
|
||||||
# engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}
|
# engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}
|
||||||
# timeout: 300000
|
# timeout: 300000
|
||||||
|
|
||||||
|
# Max allowed note text length in charactors
|
||||||
|
maxNoteTextLength: 1000
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<span v-if="visibility === 'specified'">%fa:envelope%</span>
|
<span v-if="visibility === 'specified'">%fa:envelope%</span>
|
||||||
<span v-if="visibility === 'private'">%fa:lock%</span>
|
<span v-if="visibility === 'private'">%fa:lock%</span>
|
||||||
</button>
|
</button>
|
||||||
<p class="text-count" :class="{ over: this.trimmedLength(text) > 1000 }">{{ 1000 - this.trimmedLength(text) }}</p>
|
<p class="text-count" :class="{ over: this.trimmedLength(text) > this.maxNoteTextLength }">{{ this.maxNoteTextLength - this.trimmedLength(text) }}</p>
|
||||||
<button :class="{ posting }" class="submit" :disabled="!canPost" @click="post">
|
<button :class="{ posting }" class="submit" :disabled="!canPost" @click="post">
|
||||||
{{ posting ? '%i18n:@posting%' : submitText }}<mk-ellipsis v-if="posting"/>
|
{{ posting ? '%i18n:@posting%' : submitText }}<mk-ellipsis v-if="posting"/>
|
||||||
</button>
|
</button>
|
||||||
@ -107,10 +107,17 @@ export default Vue.extend({
|
|||||||
visibleUsers: [],
|
visibleUsers: [],
|
||||||
autocomplete: null,
|
autocomplete: null,
|
||||||
draghover: false,
|
draghover: false,
|
||||||
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]')
|
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'),
|
||||||
|
maxNoteTextLength: 1000
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
(this as any).os.getMeta().then(meta => {
|
||||||
|
this.maxNoteTextLength = meta.maxNoteTextLength;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
draftId(): string {
|
draftId(): string {
|
||||||
return this.renote
|
return this.renote
|
||||||
@ -149,7 +156,7 @@ export default Vue.extend({
|
|||||||
canPost(): boolean {
|
canPost(): boolean {
|
||||||
return !this.posting &&
|
return !this.posting &&
|
||||||
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
||||||
(length(this.text.trim()) <= 1000);
|
(length(this.text.trim()) <= this.maxNoteTextLength);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<button class="cancel" @click="cancel">%fa:times%</button>
|
<button class="cancel" @click="cancel">%fa:times%</button>
|
||||||
<div>
|
<div>
|
||||||
<span class="text-count" :class="{ over: trimmedLength(text) > 1000 }">{{ 1000 - trimmedLength(text) }}</span>
|
<span class="text-count" :class="{ over: trimmedLength(text) > this.maxNoteTextLength }">{{ this.maxNoteTextLength - trimmedLength(text) }}</span>
|
||||||
<span class="geo" v-if="geo">%fa:map-marker-alt%</span>
|
<span class="geo" v-if="geo">%fa:map-marker-alt%</span>
|
||||||
<button class="submit" :disabled="!canPost" @click="post">{{ submitText }}</button>
|
<button class="submit" :disabled="!canPost" @click="post">{{ submitText }}</button>
|
||||||
</div>
|
</div>
|
||||||
@ -102,10 +102,17 @@ export default Vue.extend({
|
|||||||
visibleUsers: [],
|
visibleUsers: [],
|
||||||
useCw: false,
|
useCw: false,
|
||||||
cw: null,
|
cw: null,
|
||||||
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]')
|
recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'),
|
||||||
|
maxNoteTextLength: 1000
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
(this as any).os.getMeta().then(meta => {
|
||||||
|
this.maxNoteTextLength = meta.maxNoteTextLength;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
draftId(): string {
|
draftId(): string {
|
||||||
return this.renote
|
return this.renote
|
||||||
@ -144,7 +151,7 @@ export default Vue.extend({
|
|||||||
canPost(): boolean {
|
canPost(): boolean {
|
||||||
return !this.posting &&
|
return !this.posting &&
|
||||||
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
(1 <= this.text.length || 1 <= this.files.length || this.poll || this.renote) &&
|
||||||
(this.text.trim().length <= 1000);
|
(this.text.trim().length <= this.maxNoteTextLength);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ export default function load() {
|
|||||||
if (config.localDriveCapacityMb == null) config.localDriveCapacityMb = 256;
|
if (config.localDriveCapacityMb == null) config.localDriveCapacityMb = 256;
|
||||||
if (config.remoteDriveCapacityMb == null) config.remoteDriveCapacityMb = 8;
|
if (config.remoteDriveCapacityMb == null) config.remoteDriveCapacityMb = 8;
|
||||||
|
|
||||||
|
if (config.maxNoteTextLength == null) config.maxNoteTextLength = 1000;
|
||||||
|
|
||||||
if (config.name == null) config.name = 'Misskey';
|
if (config.name == null) config.name = 'Misskey';
|
||||||
|
|
||||||
return Object.assign(config, mixin);
|
return Object.assign(config, mixin);
|
||||||
|
@ -103,6 +103,8 @@ export type Source = {
|
|||||||
engine: string;
|
engine: string;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
maxNoteTextLength?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,7 @@ import NoteReaction from './note-reaction';
|
|||||||
import Favorite, { deleteFavorite } from './favorite';
|
import Favorite, { deleteFavorite } from './favorite';
|
||||||
import Notification, { deleteNotification } from './notification';
|
import Notification, { deleteNotification } from './notification';
|
||||||
import Following from './following';
|
import Following from './following';
|
||||||
|
import config from '../config';
|
||||||
|
|
||||||
const Note = db.get<INote>('notes');
|
const Note = db.get<INote>('notes');
|
||||||
Note.createIndex('uri', { sparse: true, unique: true });
|
Note.createIndex('uri', { sparse: true, unique: true });
|
||||||
@ -29,7 +30,7 @@ Note.createIndex({
|
|||||||
export default Note;
|
export default Note;
|
||||||
|
|
||||||
export function isValidText(text: string): boolean {
|
export function isValidText(text: string): boolean {
|
||||||
return length(text.trim()) <= 1000 && text.trim() != '';
|
return length(text.trim()) <= config.maxNoteTextLength && text.trim() != '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidCw(text: string): boolean {
|
export function isValidCw(text: string): boolean {
|
||||||
|
@ -49,6 +49,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
|||||||
swPublickey: config.sw ? config.sw.public_key : null,
|
swPublickey: config.sw ? config.sw.public_key : null,
|
||||||
hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined,
|
hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined,
|
||||||
bannerUrl: meta.bannerUrl,
|
bannerUrl: meta.bannerUrl,
|
||||||
|
maxNoteTextLength: config.maxNoteTextLength,
|
||||||
|
|
||||||
features: {
|
features: {
|
||||||
registration: !meta.disableRegistration,
|
registration: !meta.disableRegistration,
|
||||||
|
Loading…
Reference in New Issue
Block a user