From d0cd22f5b426003167648a9eb2f369f9fee537d7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 Sep 2018 17:08:17 -0600 Subject: [PATCH 1/7] Update StatusController --- app/Http/Controllers/StatusController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index a86209c3e..04c42747e 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -85,7 +85,13 @@ class StatusController extends Controller } $this->validate($request, [ - 'photo.*' => 'required|mimes:jpeg,png,gif|max:'.config('pixelfed.max_photo_size'), + 'photo.*' => function() { + return [ + 'required', + 'mimes:' . config('pixelfed.media_types'), + 'max:' . config('pixelfed.max_photo_size'), + ]; + }, 'caption' => 'string|max:'.config('pixelfed.max_caption_length'), 'cw' => 'nullable|string', 'filter_class' => 'nullable|string', From 2982182b3df8dd665c4c127991d50de9eb578a31 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 Sep 2018 17:25:33 -0600 Subject: [PATCH 2/7] Update Profile model --- app/Profile.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/Profile.php b/app/Profile.php index 92d1bad3f..b69bf74b9 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -196,6 +196,30 @@ class Profile extends Model ->pluck('filterable_id'); } + public function blockedIds() + { + return UserFilter::whereUserId($this->id) + ->whereFilterableType('App\Profile') + ->whereFilterType('block') + ->pluck('filterable_id'); + } + + public function mutedProfileUrls() + { + $ids = $this->mutedIds(); + return $this->whereIn('id', $ids)->get()->map(function($i) { + return $i->url(); + }); + } + + public function blockedProfileUrls() + { + $ids = $this->blockedIds(); + return $this->whereIn('id', $ids)->get()->map(function($i) { + return $i->url(); + }); + } + public function reports() { return $this->hasMany(Report::class, 'profile_id'); From c44dcca592badfec5a56925d095c1683db871f31 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 Sep 2018 20:17:55 -0600 Subject: [PATCH 3/7] Update 2FA checkpoint view, fixes #470 --- resources/views/auth/checkpoint.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/checkpoint.blade.php b/resources/views/auth/checkpoint.blade.php index 24c4ae775..ae415a5b4 100644 --- a/resources/views/auth/checkpoint.blade.php +++ b/resources/views/auth/checkpoint.blade.php @@ -16,7 +16,7 @@
- + @if ($errors->has('code')) From e0760ff74af1cb152b176de285840573ed730462 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 26 Sep 2018 22:08:06 -0600 Subject: [PATCH 4/7] Update timeline.js --- resources/assets/js/timeline.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/timeline.js b/resources/assets/js/timeline.js index bae140581..403524064 100644 --- a/resources/assets/js/timeline.js +++ b/resources/assets/js/timeline.js @@ -3,7 +3,12 @@ $(document).ready(function() { $('.container.timeline-container').removeClass('d-none'); let elem = document.querySelector('.timeline-feed'); pixelfed.fetchLikes(); - + $('video').on('play', function() { + activated = this; + $('video').each(function() { + if(this != activated) this.pause(); + }); + }); let infScroll = new InfiniteScroll( elem, { path: '.pagination__next', append: '.timeline-feed', @@ -19,6 +24,12 @@ $(document).ready(function() { $(this).addClass('d-none'); } }); + $('video').on('play', function() { + activated = this; + $('video').each(function() { + if(this != activated) this.pause(); + }); + }); }); From 6d4482882ca9e5ef72586161606a71bf98493034 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 26 Sep 2018 22:18:47 -0600 Subject: [PATCH 5/7] Update searchform.js --- resources/assets/js/components/searchform.js | 30 +++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/components/searchform.js b/resources/assets/js/components/searchform.js index e23843edf..47fd833d4 100644 --- a/resources/assets/js/components/searchform.js +++ b/resources/assets/js/components/searchform.js @@ -13,21 +13,21 @@ $(document).ready(function() { name: 'search', display: 'value', source: queryEngine, - limit: 20, + limit: 40, templates: { empty: [ - '
', - 'unable to find any matches', + '
', + 'No Results Found', '
' ].join('\n'), suggestion: function(data) { let type = data.type; - let res = null; + let res = false; switch(type) { case 'hashtag': res = '' + '
' + - '
#
' + + '
' + '
' + '

'+data.value+'

' + '

'+data.count+' posts

' + @@ -38,7 +38,7 @@ $(document).ready(function() { case 'profile': res = '
' + '
' + - '
' + + '
' + '
' + '

'+data.name+'

' + '

'+data.value+'

' + @@ -46,8 +46,24 @@ $(document).ready(function() { '
' + '
'; break; + case 'status': + res = '' + + '
' + + '
' + + '
' + + '

'+data.name+'

' + + '

'+data.value+'

' + + '
' + + '
' + + '
'; + break; + default: + res = false; + break; + } + if(res !== false) { + return res; } - return res; } } }); From 55362f3b5915abbc0c5d97a1c46bafccfa033aee Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 26 Sep 2018 22:22:36 -0600 Subject: [PATCH 6/7] Update compiled assets --- public/css/app.css | Bin 217985 -> 217019 bytes public/js/app.js | Bin 450227 -> 450680 bytes public/js/timeline.js | Bin 1557 -> 1773 bytes public/mix-manifest.json | Bin 250 -> 251 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 4114dad8e6c2f4562e816bce712aa797dbae7978..5e128d91597a54f1a51800105dd4c33a4082d9c7 100644 GIT binary patch delta 1078 zcmah|U2IfE6waBuKmA|m&(c~pZdZt~bS`(dOQClok|?0^V@XIbDHw0}&hB2kKbyOA z3+V=}BSTxaxXjAppB(nBeIU&&tfUPs zWnArqmoV52UAx9C&*VnQWJdl)=>S*1_SCL3v~&E_9GJc*0EX_SRJPm(KB%KyF&caj#N2~s<2ZXQm+Vk)P9;v}5 z3<=n~1azq?wVX-nYIcE9Ui7T-3hu4Jo+Y%cj+XBW?-#rZSxFQHd?lg3DtP^(-@wgF zP{qYH(BGA=TfoxXf?-pW<+&=Sr%s6|b{v8haef}&CCg<>4Fcl(8tgoZi6mKzGf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= dP+ou&wAD^Rne>-He#}#|fs1MA&^C^D{{xHE{0RU6 diff --git a/public/js/app.js b/public/js/app.js index 65c2a63a619900f07550b67fa4b5fc621e8bd81e..bb7e610774338d1910ba130e55c053964d394a9b 100644 GIT binary patch delta 9237 zcmZX433wCL+W&KA&ZM-otX)_tv;oSDorac0AY~d!*_C}0ODSnGnFKRQn@kFo7D4ff z%f%&E4k!w!S4CyC2$h|5(F1lKEz+g1F$D!5$zR7C&3lLB&||MT?eJ7<6Q_dV}P z+Y7ya-q(BkTB&nWEF35*FV-}xq{M1zVMoUaxv7mEva(uQ7KfvO*kU!zs+gk}>%<(T zsS{GayqFwz`F)XyoY1XVVN;JKEj6C%>G0%VIx;b8>G39CM2)jE%u$%S(=n2bS?j1H z@wT!IU$-hXj`Kp{gsZ&yjkO6)GU`TX@y+LgdUIjOuePW=~Ru>_M-9( zv()K!mKtqe6cxoq6P;P9P>!iJ$Z;3&NGj;LAyu4#k&+U*i8cO23flIhssv)Tox8V! z5F<5+Iq`o6^W++yCU-O$i6|~#LxUa-$ju%z^>;Q2bH8Q1GP{{tQ#-Gw)-Tfi7WQr{ z+*H^B!y`A(6Gfv{VMpeI;dhjDNIm`3*BqU;jazmIsk^u5rb645)U55fZGYdsT_Q%? zoSnUdK4wcxvFWn(ge6;wqAU#ufKi-=a{aBWFjOxmuXH#Wt$w1+*I{H zx?^zeKit6h9(<$m=xY=4|J&D$^#4Aorq_Gp>z>y?=xm%{U#vOR2}*0~!2>0!mIM9U zUOupv78pR>Xh&RE6mYgUO-fth&4XE8Oigz+_~OulDX{>jW6CiXHf=pN8i?;bc6BGy z6%5A{R&^*G3AoKv&*K9zJo@-dpmp!@9*{}f))VIl=zHqJF&(;?7T1IeT2W;D&li~# z^RvF{eTAV#J>ixXIp(q4p_Z1o;;E^1``l(F7#S@oiOP_GnoywyaU~dw%YLoil8sc& zSEU_|nueN4ZLL-;o2k3MDxGGyB6`%YLY0xSvPwk`Y6gZunZKP4CR$ohsSL|pLDV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Xe|)lnP{@D;Q1i@Q0foN{(<9=?=EyDBQ$5ZPGVVHxmO+ zE82kf`#2Q%$QH@Nom~DlsjApegRXRWp+xhS@P_G)8==Vc(FU#YQfrbPuuzF!vQ4@N zo9P!f3t_Xq+ofh69@!4*`>v)OQBe5T;Xh1!)lR7^s+jhZFG)@wP+xmpn#~0=XfLz` z75Tl=*bKn_2c>zu4ENw+N$He>bhg%CSDe6``S9|R#^L*v zknPOTP$Nv}hU5w{C#PU*w4@c;8uOqvZAIk z8qfR}zi~$H38@lPTz5iRQV6Nbc;3MOG0fplW~eEIL->~t{w$-W2kh@oNZm88LLH%F zGvvZr*i%yGF2n1-v!hspu0Xo0BFW$X8;2PxPtLW5VWwUAztTO(O6*t9NvpX^c@@VZ zfR7Z%YVd2pFvoD};8jrg$u^gxPbae$S5>@0+6P>Y*CvZ*t;rs3b}WXv4QO$EkPGd- z@TP}AuaDOF>#yBoq2pz)n1>fR2)}{zD(kVOju-Ke#va+`;MbWg+Z>yR@c%-&Xol%? zqG|xoN7k71KjPfLA3u==+_&BFC2AjR;Y*Ho99#afgJ*l>6-QMD@>vW2V3E3RR}M1= XIWiok(gL2b-3J^w_JUU&|L*sHqV_O^ diff --git a/public/js/timeline.js b/public/js/timeline.js index 14cc9d76a62f7ecca471045add4b205f20299023..f135d889a7962f025e9a09995e1ae3c4f20274c2 100644 GIT binary patch delta 731 zcmcIi!D$AVnKi46>(lDC4mrYDK7fR&W+tXp-XWw&fKw)X)vD}DY z3XZSLYvBPKZqU3P>8_=NIWf1(y)~U?X<2eNfTWX~+6vl~dVaX+wN_nd zkXB_HY0dTUJO_!A2C&L?rMSLczIg{3svHVq;iY#Kc)aXkA#=7cZySI6b2c-rXo<;= znEtAZk0z%Hy}?nklo6-I4(UcniSg6q@ECiFO0y?ST5eUXk3`GE(aAs4SrK5+scrl< znN2X>+xoiR=WJzia7-vNmsMqY$>iNt5mIt}l_KOC&rK~ya7eRrK0V~L+h5jW_WwOhKhQqUUDjNH#ZGO|7C;F5cX{QE~ zigS50*2Ye<>WLDSB%JE&`C#h~Z}VYU5>=a+Vt?FHJd~o{`P01RS3)w&a{-9wq8?8q z1BMG&t}9Asv%%<6=4g?H0(oroSQ>k~u(@1Ap)RIo{?Te_Pdz5VQqoVmupJ#G7(jrf z!xS?aR8GC*WDp*rP7f9lW04-D%o58dqDwt--TuGrEOoN(DQx(RS`mbJ?9!&7{Ec2U>0x@8OG(b@&659xYs2rh$r&gn+YN?yA9r! g!L(KmFG|?pl3j=$Il6?JNnXH^Ir9 e7Z62j1tfwt#!#5&xi3-w1_RTP?Z`r;^R6FRI~FDY From 958b5b402f2cbb463a681b40cf5cbbc591f53bea Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 26 Sep 2018 23:00:45 -0600 Subject: [PATCH 7/7] Update SearchController --- app/Http/Controllers/SearchController.php | 95 ++++++++++++++++------- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 2244004c1..247120162 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -2,43 +2,86 @@ namespace App\Http\Controllers; +use Auth; use App\Hashtag; use App\Profile; +use App\Status; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; class SearchController extends Controller { + public function __construct() + { + $this->middleware('auth'); + } + public function searchAPI(Request $request, $tag) { - $res = Cache::remember('api:search:tag:'.$tag, 1440, function () use ($tag) { - $res = Hashtag::where('slug', 'like', '%'.$tag.'%')->get(); - $tags = $res->map(function ($item, $key) { - return [ - 'count' => $item->posts()->count(), - 'url' => $item->url(), - 'type' => 'hashtag', - 'value' => $item->name, - 'tokens' => explode('-', $item->name), - 'name' => null, - ]; - }); - $res = Profile::where('username', 'like', '%'.$tag.'%')->get(); - $profiles = $res->map(function ($item, $key) { - return [ - 'count' => 0, - 'url' => $item->url(), - 'type' => 'profile', - 'value' => $item->username, - 'tokens' => [$item->username], - 'name' => $item->name, - ]; - }); - $tags = $tags->push($profiles[0]); + if(mb_strlen($tag) < 3) { + return; + } + $hash = hash('sha256', $tag); + $tokens = Cache::remember('api:search:tag:'.$hash, 60, function () use ($tag) { + $tokens = collect([]); + $hashtags = Hashtag::select('id', 'name', 'slug')->where('slug', 'like', '%'.$tag.'%')->limit(20)->get(); + if($hashtags->count() > 0) { + $tags = $hashtags->map(function ($item, $key) { + return [ + 'count' => $item->posts()->count(), + 'url' => $item->url(), + 'type' => 'hashtag', + 'value' => $item->name, + 'tokens' => explode('-', $item->name), + 'name' => null, + ]; + }); + $tokens->push($tags); + } + $users = Profile::select('username', 'name', 'id')->where('username', 'like', '%'.$tag.'%')->limit(20)->get(); - return $tags; + if($users->count() > 0) { + $profiles = $users->map(function ($item, $key) { + return [ + 'count' => 0, + 'url' => $item->url(), + 'type' => 'profile', + 'value' => $item->username, + 'tokens' => [$item->username], + 'name' => $item->name, + ]; + }); + $tokens->push($profiles); + } + + return $tokens; }); + $posts = Status::select('id', 'profile_id', 'caption', 'created_at') + ->whereHas('media') + ->whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->whereProfileId(Auth::user()->profile->id) + ->where('caption', 'like', '%'.$tag.'%') + ->orderBy('created_at', 'desc') + ->get(); - return response()->json($res); + if($posts->count() > 0) { + $posts = $posts->map(function($item, $key) { + return [ + 'count' => 0, + 'url' => $item->url(), + 'type' => 'status', + 'value' => 'Posted '.$item->created_at->diffForHumans(), + 'tokens' => [$item->caption], + 'name' => $item->caption, + 'thumb' => $item->thumb(), + ]; + }); + $tokens = $tokens->push($posts); + } + if($tokens->count() > 0) { + $tokens = $tokens[0]; + } + return response()->json($tokens); } }