mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update Extractor
This commit is contained in:
parent
070dc14f31
commit
59a1346277
1 changed files with 8 additions and 13 deletions
|
@ -10,6 +10,7 @@
|
|||
namespace App\Util\Lexer;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Status;
|
||||
|
||||
/**
|
||||
* Twitter Extractor Class.
|
||||
|
@ -121,7 +122,7 @@ class Extractor extends Regex
|
|||
$hashtagsOnly[] = $hashtagWithIndex['hashtag'];
|
||||
}
|
||||
|
||||
return $hashtagsOnly;
|
||||
return array_slice($hashtagsOnly, 0, Status::MAX_HASHTAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,12 +135,6 @@ class Extractor extends Regex
|
|||
public function extractCashtags($tweet = null)
|
||||
{
|
||||
$cashtagsOnly = [];
|
||||
$cashtagsWithIndices = $this->extractCashtagsWithIndices($tweet);
|
||||
|
||||
foreach ($cashtagsWithIndices as $cashtagWithIndex) {
|
||||
$cashtagsOnly[] = $cashtagWithIndex['cashtag'];
|
||||
}
|
||||
|
||||
return $cashtagsOnly;
|
||||
}
|
||||
|
||||
|
@ -159,7 +154,7 @@ class Extractor extends Regex
|
|||
$urlsOnly[] = $urlWithIndex['url'];
|
||||
}
|
||||
|
||||
return $urlsOnly;
|
||||
return array_slice($urlsOnly, 0, Status::MAX_LINKS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,7 +272,7 @@ class Extractor extends Regex
|
|||
}
|
||||
|
||||
if (!$checkUrlOverlap) {
|
||||
return $tags;
|
||||
return array_slice($tags, 0, Status::MAX_HASHTAGS);
|
||||
}
|
||||
|
||||
// check url overlap
|
||||
|
@ -292,7 +287,7 @@ class Extractor extends Regex
|
|||
$validTags[] = $entity;
|
||||
}
|
||||
|
||||
return $validTags;
|
||||
return array_slice($validTags, 0, Status::MAX_HASHTAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,7 +385,7 @@ class Extractor extends Regex
|
|||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
return array_slice($urls, 0, Status::MAX_LINKS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,7 +410,7 @@ class Extractor extends Regex
|
|||
$usernamesOnly[] = $mention;
|
||||
}
|
||||
|
||||
return $usernamesOnly;
|
||||
return array_slice($usernamesOnly, 0, Status::MAX_MENTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -472,7 +467,7 @@ class Extractor extends Regex
|
|||
$results[] = $entity;
|
||||
}
|
||||
|
||||
return $results;
|
||||
return array_slice($results, 0, Status::MAX_MENTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue