Apply tag length limit from AP (#3536)

This commit is contained in:
MeiMei 2018-12-07 21:01:43 +09:00 committed by syuilo
parent f6d0e11b47
commit de3a658c64

View file

@ -161,6 +161,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
const combinedTokens = tokens.concat(cwTokens);
tags = data.apHashtags || extractHashtags(combinedTokens);
tags = tags.filter(tag => tag.length <= 100);
emojis = data.apEmojis || extractEmojis(combinedTokens);
@ -467,9 +468,7 @@ function extractHashtags(tokens: ReturnType<typeof parse>): string[] {
const extract = (tokens: Node[]) => {
tokens.filter(x => x.name === 'hashtag').forEach(x => {
if (x.props.hashtag.length <= 100) {
hashtags.push(x.props.hashtag);
}
});
tokens.filter(x => x.children).forEach(x => {
extract(x.children);