浏览代码

Update Hashtag limit

Daniel Supernault 6 年之前
父节点
当前提交
7591eadbd1
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 3 0
      app/Jobs/StatusPipeline/StatusEntityLexer.php
  2. 3 1
      app/Util/Lexer/Extractor.php

+ 3 - 0
app/Jobs/StatusPipeline/StatusEntityLexer.php

@@ -89,6 +89,9 @@ class StatusEntityLexer implements ShouldQueue
         $status = $this->status;
         $status = $this->status;
 
 
         foreach ($tags as $tag) {
         foreach ($tags as $tag) {
+            if(mb_strlen($tag) > 124) {
+                continue;
+            }
             DB::transaction(function () use ($status, $tag) {
             DB::transaction(function () use ($status, $tag) {
                 $slug = str_slug($tag, '-', false);
                 $slug = str_slug($tag, '-', false);
                 $hashtag = Hashtag::firstOrCreate(
                 $hashtag = Hashtag::firstOrCreate(

+ 3 - 1
app/Util/Lexer/Extractor.php

@@ -264,7 +264,9 @@ class Extractor extends Regex
             if (preg_match(self::$patterns['end_hashtag_match'], $outer[0])) {
             if (preg_match(self::$patterns['end_hashtag_match'], $outer[0])) {
                 continue;
                 continue;
             }
             }
-
+            if(mb_strlen($hashtag[0]) > 124) {
+                continue;
+            }
             $tags[] = [
             $tags[] = [
                 'hashtag' => $hashtag[0],
                 'hashtag' => $hashtag[0],
                 'indices' => [$start_position, $end_position],
                 'indices' => [$start_position, $end_position],