@@ -743,7 +743,11 @@ public function instances(Request $request)
743743 if (str_starts_with ($ search , 'software: ' )) {
744744 $ software = trim (substr ($ search , 9 ));
745745 if (! empty ($ software )) {
746- $ query ->where ('software ' , 'like ' , $ software .'% ' );
746+ if ($ software === 'unknown ' ) {
747+ $ query ->whereNull ('software ' );
748+ } else {
749+ $ query ->where ('software ' , 'like ' , $ software .'% ' );
750+ }
747751 }
748752 } elseif (str_starts_with ($ search , 'description: ' )) {
749753 $ desc = trim (substr ($ search , 12 ));
@@ -893,6 +897,8 @@ public function updateInstanceRefreshData(Request $request, $id)
893897 $ instance ->report_count = Report::where ('domain ' , $ instance ->domain )->count ();
894898 $ instance ->save ();
895899
900+ FetchInstanceNodeinfo::dispatch ($ instance )->onQueue ('actor-update ' );
901+
896902 return $ this ->success ();
897903 }
898904
@@ -926,11 +932,11 @@ public function instanceStats(Request $request)
926932 {
927933 $ res = [
928934 [
929- 'name ' => 'Total Instances ' ,
935+ 'name ' => 'Total ' ,
930936 'value ' => Instance::whereNotNull ('software ' )->whereFederationState (5 )->count (),
931937 ],
932938 [
933- 'name ' => 'New (past 24h) ' ,
939+ 'name ' => 'New ' ,
934940 'value ' => Instance::whereNotNull ('software ' )->whereFederationState (5 )->where ('created_at ' , '> ' , now ()->subHours (24 ))->count (),
935941 ],
936942 [
@@ -946,6 +952,78 @@ public function instanceStats(Request $request)
946952 return $ this ->data ($ res );
947953 }
948954
955+ public function instanceAdvancedStats ()
956+ {
957+ $ totalInstances = Instance::count ();
958+ $ activeInstances = Instance::where ('is_blocked ' , false )->count ();
959+ $ allowedVideoPosts = Instance::where ('allow_video_posts ' , true )->count ();
960+ $ allowedInFyf = Instance::where ('allow_videos_in_fyf ' , true )->count ();
961+
962+ $ softwareStats = Instance::select ('software ' )
963+ ->selectRaw ('COUNT(*) as count ' )
964+ ->selectRaw ('SUM(CASE WHEN allow_video_posts = 1 THEN 1 ELSE 0 END) as allow_video_posts_count ' )
965+ ->groupBy ('software ' )
966+ ->orderByDesc ('count ' )
967+ ->get ();
968+
969+ return response ()->json ([
970+ 'data ' => [
971+ 'stats ' => [
972+ ['name ' => 'Total Instances ' , 'value ' => $ totalInstances ],
973+ ['name ' => 'Active Instances ' , 'value ' => $ activeInstances ],
974+ ['name ' => 'Video Posts Allowed ' , 'value ' => $ allowedVideoPosts ],
975+ ['name ' => 'FYF Allowed ' , 'value ' => $ allowedInFyf ],
976+ ],
977+ 'software_stats ' => $ softwareStats ,
978+ ],
979+ ]);
980+ }
981+
982+ public function manageInstanceToggleBySoftware (Request $ request )
983+ {
984+ $ request ->validate ([
985+ 'software ' => 'required|string ' ,
986+ 'allow_video_posts ' => 'required|boolean ' ,
987+ ]);
988+
989+ $ software = $ request ->software ;
990+ $ allowVideoPosts = (bool ) $ request ->allow_video_posts ;
991+ $ updatedCount = Instance::where ('software ' , $ software )
992+ ->update (['allow_video_posts ' => $ request ->allow_video_posts ]);
993+
994+ app (AdminAuditLogService::class)->logInstanceSoftwareUpdateAllowVideoPosts ($ request ->user (), ['software ' => $ software , 'allow_video_posts ' => $ allowVideoPosts ]);
995+
996+ return response ()->json ([
997+ 'data ' => [
998+ 'updated_count ' => $ updatedCount ,
999+ ],
1000+ ]);
1001+ }
1002+
1003+ public function manageInstanceToggleByDomains (Request $ request )
1004+ {
1005+ $ request ->validate ([
1006+ 'domains ' => 'required|array ' ,
1007+ 'domains.* ' => 'string ' ,
1008+ 'allow_video_posts ' => 'required|boolean ' ,
1009+ ]);
1010+
1011+ $ domains = array_map (function ($ domain ) {
1012+ return parse_url ($ domain , PHP_URL_HOST ) ?: $ domain ;
1013+ }, $ request ->domains );
1014+
1015+ $ updatedCount = Instance::whereIn ('domain ' , $ domains )
1016+ ->update (['allow_video_posts ' => $ request ->allow_video_posts ]);
1017+
1018+ app (AdminAuditLogService::class)->logInstanceDomainsUpdateAllowVideoPosts ($ request ->user (), ['domains ' => $ domains , 'allow_video_posts ' => $ request ->allow_video_posts ]);
1019+
1020+ return response ()->json ([
1021+ 'data ' => [
1022+ 'updated_count ' => $ updatedCount ,
1023+ ],
1024+ ]);
1025+ }
1026+
9491027 public function instanceCreate (Request $ request )
9501028 {
9511029 $ validated = $ request ->validate ([
@@ -1156,6 +1234,10 @@ public function deleteAdminInvite(Request $request, $id)
11561234
11571235 private function applySorting ($ query , $ sort )
11581236 {
1237+ if ($ sort === 'allow_video_posts ' ) {
1238+ return $ query ->where ('allow_video_posts ' , 1 );
1239+ }
1240+
11591241 if ($ sort === 'unprocessed ' ) {
11601242 return $ query ->where ('status ' , 1 );
11611243 }
0 commit comments