@@ -35,8 +35,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
3535 user_priority <- ACL . get_user_priority ( conn ) ,
3636 threads <- Thread . recent ( user , user_priority ) do
3737 render ( conn , :recent , % { threads: threads } )
38- else
39- _ -> ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot fetch recent threads" )
4038 end
4139 end
4240
@@ -174,10 +172,11 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
174172 user <- Guardian.Plug . current_resource ( conn ) ,
175173 user_priority <- ACL . get_user_priority ( conn ) ,
176174 :ok <- ACL . allow! ( conn , "threads.byBoard" ) ,
177- { :can_read , { :ok , true } } <-
178- { :can_read , Board . get_read_access_by_id ( board_id , user_priority ) } ,
179- { :ok , write_access } <- Board . get_write_access_by_id ( board_id , user_priority ) ,
175+ { :ok , can_read } <- Board . get_read_access_by_id ( board_id , user_priority ) ,
176+ { :can_read , true } <- { :can_read , can_read } ,
180177 { :ok , board_banned } <- BoardBan . banned_from_board? ( user , board_id: board_id ) ,
178+ { :board_banned , false } <- { :board_banned , board_banned } ,
179+ { :ok , write_access } <- Board . get_write_access_by_id ( board_id , user_priority ) ,
181180 { :ok , watching_board } <- WatchBoard . user_is_watching ( user , board_id ) ,
182181 board_mapping <- BoardMapping . all ( ) ,
183182 board_moderators <- BoardModerator . all ( ) ,
@@ -208,20 +207,14 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
208207 { :error , :board_does_not_exist } ->
209208 ErrorHelpers . render_json_error ( conn , 400 , "Error, board does not exist" )
210209
211- { :can_read , { :ok , false } } ->
210+ { :can_read , false } ->
212211 ErrorHelpers . render_json_error ( conn , 403 , "Unauthorized, you do not have permission" )
213212
214- { :can_read , { :error , :board_does_not_exist } } ->
215- ErrorHelpers . render_json_error ( conn , 400 , "Read error, board does not exist" )
216-
217- { :board_banned , { :ok , true } } ->
213+ { :board_banned , true } ->
218214 ErrorHelpers . render_json_error ( conn , 403 , "Unauthorized, you are banned from this board" )
219215
220216 { :has_threads , false } ->
221217 ErrorHelpers . render_json_error ( conn , 404 , "Error, requested threads not found in board" )
222-
223- _ ->
224- ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot get threads by board" )
225218 end
226219 end
227220
@@ -340,9 +333,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
340333 "Account must be active to unwatch thread"
341334 )
342335
343- { :error , data } ->
344- ErrorHelpers . render_json_error ( conn , 400 , data )
345-
346336 _ ->
347337 ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot unwatch thread" )
348338 end
@@ -401,9 +391,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
401391 "Account must be active to modify lock on thread"
402392 )
403393
404- { :error , data } ->
405- ErrorHelpers . render_json_error ( conn , 400 , data )
406-
407394 _ ->
408395 ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot lock thread" )
409396 end
@@ -462,9 +449,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
462449 "Account must be active to modify sticky on thread"
463450 )
464451
465- { :error , data } ->
466- ErrorHelpers . render_json_error ( conn , 400 , data )
467-
468452 _ ->
469453 ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot sticky thread" )
470454 end
@@ -638,9 +622,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
638622 400 ,
639623 "Error, cannot convert slug, thread does not exist"
640624 )
641-
642- _ ->
643- ErrorHelpers . render_json_error ( conn , 400 , "Error, cannot convert thread slug to id" )
644625 end
645626 end
646627
@@ -663,7 +644,7 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
663644 |> send_resp ( 200 , [ ] )
664645 |> halt ( )
665646 else
666- { :error , :board_does_not_exist } ->
647+ { :can_read , { : error, :board_does_not_exist } } ->
667648 ErrorHelpers . render_json_error (
668649 conn ,
669650 400 ,
0 commit comments