Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 91b1495

Browse files
committed
feat(blog-thread): remove matcher old debug
1 parent f9e04b7 commit 91b1495

File tree

5 files changed

+16
-35
lines changed

5 files changed

+16
-35
lines changed

lib/groupher_server/cms/helper/matcher_old.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ defmodule GroupherServer.CMS.Helper.MatcherOld do
3030
def match_action(:post, :community),
3131
do: {:ok, %{target: Post, reactor: Community}}
3232

33+
def match_action(:post, :comment),
34+
do: {:ok, %{target: Post, reactor: PostComment, preload: :author}}
35+
3336
#########################################
3437
## jobs ...
3538
#########################################

lib/groupher_server_web/middleware/passport_loader.ex

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,10 @@ defmodule GroupherServerWeb.Middleware.PassportLoader do
6767
end
6868
end
6969

70-
def call(resolution, _) do
71-
# TODO communiy in args
72-
resolution
73-
end
70+
def call(resolution, _), do: resolution
7471

75-
def load_source(resolution, content) do
76-
arguments = resolution.arguments |> Map.merge(%{passport_source: content})
77-
%{resolution | arguments: arguments}
72+
def load_source(%{arguments: arguments} = resolution, content) do
73+
%{resolution | arguments: Map.put(arguments, :passport_source, content)}
7874
end
7975

8076
# 取得 content 里面的 conmunities 字段
@@ -92,34 +88,22 @@ defmodule GroupherServerWeb.Middleware.PassportLoader do
9288
{:ok, _, react} = parse_source(args)
9389

9490
case react == :comment do
95-
true ->
96-
{:ok, action.preload}
97-
98-
false ->
99-
{:ok, [action.preload, parse_base(args)]}
91+
true -> {:ok, action.preload}
92+
false -> {:ok, [action.preload, parse_base(args)]}
10093
end
10194
end
10295

10396
def load_owner_info(%{context: %{cur_user: cur_user}} = resolution, react, content) do
10497
content_author_id =
10598
cond do
106-
react == :article_comment ->
107-
content.author.id
108-
109-
react == :comment ->
110-
content.author.id
111-
112-
true ->
113-
content.author.user_id
99+
react == :article_comment -> content.author.id
100+
react == :comment -> content.author.id
101+
true -> content.author.user_id
114102
end
115103

116104
case content_author_id == cur_user.id do
117-
true ->
118-
arguments = resolution.arguments |> Map.merge(%{passport_is_owner: true})
119-
%{resolution | arguments: arguments}
120-
121-
_ ->
122-
resolution
105+
true -> %{resolution | arguments: Map.put(resolution.arguments, :passport_is_owner, true)}
106+
_ -> resolution
123107
end
124108
end
125109

@@ -128,9 +112,7 @@ defmodule GroupherServerWeb.Middleware.PassportLoader do
128112
parse_source(source: [thread, react])
129113
end
130114

131-
defp parse_source(args, _resolution) do
132-
parse_source(args)
133-
end
115+
defp parse_source(args, _resolution), do: parse_source(args)
134116

135117
defp parse_source(args) do
136118
case Keyword.has_key?(args, :source) do
@@ -142,7 +124,5 @@ defmodule GroupherServerWeb.Middleware.PassportLoader do
142124
defp match_source([thread, react]), do: {:ok, thread, react}
143125
defp match_source(thread), do: {:ok, thread, :self}
144126

145-
defp parse_base(args) do
146-
Keyword.get(args, :base) || :communities
147-
end
127+
defp parse_base(args), do: Keyword.get(args, :base) || :communities
148128
end

test/groupher_server_web/mutation/cms/articles/blog_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ defmodule GroupherServer.Test.Mutation.Articles.Blog do
4848
}
4949
}
5050
"""
51-
@tag :wip
5251
test "create blog with valid attrs and make sure author exsit" do
5352
{:ok, user} = db_insert(:user)
5453
user_conn = simu_conn(:user, user)

test/groupher_server_web/mutation/cms/old_post_comment_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ defmodule GroupherServer.Test.Mutation.OldPostComment do
107107
}
108108
}
109109
"""
110-
110+
@tag :wip
111111
test "comment owner can delete comment", ~m(user community post)a do
112112
variables = %{community: community.raw, id: post.id, body: "this a comment"}
113113

test/groupher_server_web/query/cms/old_post_comment_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ defmodule GroupherServer.Test.Query.OldPostComment do
219219
}
220220
}
221221
"""
222-
@tag :wip
223222
test "guest user can get replies info", ~m(guest_conn post user community)a do
224223
body = "test comment"
225224

0 commit comments

Comments
 (0)