Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cover/excoveralls.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion lib/groupher_server/cms/delegates/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ defmodule GroupherServer.CMS.Delegate.Helper do
%User{} = user,
type \\ :article
) do
IO.inspect("hello?")
supported_emotions = get_supported_mentions(type)

new_entries =
Expand Down
1 change: 0 additions & 1 deletion lib/groupher_server_web/resolvers/cms_resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do
end

def paged_articles(_root, ~m(thread filter)a, %{context: %{cur_user: user}}) do
IO.inspect(filter, label: "the filter")
CMS.paged_articles(thread, filter, user)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server_web/schema/Helper/queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule GroupherServerWeb.Schema.Helper.Queries do
@desc unquote("get paged #{action}ed users of an article")
field unquote(:"#{action}ed_users"), :paged_users do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, non_null(:paged_filter))

middleware(M.PageSizeProof)
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server_web/schema/account/account_mutations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule GroupherServerWeb.Schema.Account.Mutations do
field :add_to_collect, :collect_folder do
arg(:article_id, non_null(:id))
arg(:folder_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
resolve(&R.Accounts.add_to_collect/3)
Expand All @@ -82,7 +82,7 @@ defmodule GroupherServerWeb.Schema.Account.Mutations do
field :remove_from_collect, :collect_folder do
arg(:article_id, non_null(:id))
arg(:folder_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
resolve(&R.Accounts.remove_from_collect/3)
Expand Down
8 changes: 4 additions & 4 deletions lib/groupher_server_web/schema/cms/cms_misc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ defmodule GroupherServerWeb.Schema.CMS.Misc do
value(:radar)
end

enum :cms_thread do
enum :thread do
value(:post)
value(:job)
value(:user)
Expand Down Expand Up @@ -251,19 +251,19 @@ defmodule GroupherServerWeb.Schema.CMS.Misc do

@desc "common filter for upvoted articles"
input_object :upvoted_articles_filter do
field(:thread, :cms_thread)
field(:thread, :thread)
pagination_args()
end

@desc "common filter for collect folders"
input_object :collect_folders_filter do
field(:thread, :cms_thread)
field(:thread, :thread)
pagination_args()
end

@desc "common filter for collect articles"
input_object :collected_articles_filter do
field(:thread, :cms_thread)
field(:thread, :thread)
pagination_args()
end

Expand Down
12 changes: 6 additions & 6 deletions lib/groupher_server_web/schema/cms/cms_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
field :partial_tags, list_of(:tag) do
arg(:community_id, :id)
arg(:community, :string)
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:all, :boolean, default_value: false)

resolve(&R.CMS.get_tags/3)
Expand All @@ -115,7 +115,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
field :paged_article_comments, :paged_article_comments do
arg(:id, non_null(:id))
arg(:mode, :article_comments_mode, default_value: :replies)
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, :comments_filter)

middleware(M.PageSizeProof)
Expand All @@ -125,7 +125,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
@desc "get paged article comments participators"
field :paged_article_comments_participators, :paged_users do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, :paged_filter)

middleware(M.PageSizeProof)
Expand All @@ -144,7 +144,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
@desc "get paged comments"
field :paged_comments, :paged_comments do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, :comments_filter)

middleware(M.PageSizeProof)
Expand All @@ -154,7 +154,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
@desc "get paged comments participators"
field :paged_comments_participators, :paged_users do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, :paged_filter)

middleware(M.PageSizeProof)
Expand All @@ -165,7 +165,7 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
# TODO: remove
field :comments, :paged_comments do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:filter, :comments_filter)

middleware(M.PageSizeProof)
Expand Down
6 changes: 3 additions & 3 deletions lib/groupher_server_web/schema/cms/cms_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
timestamp_fields()
end

object :thread do
object :thread_item do
field(:id, :id)
field(:title, :string)
field(:raw, :string)
Expand Down Expand Up @@ -232,7 +232,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
field(:index, :integer)
field(:logo, :string)
field(:author, :user, resolve: dataloader(CMS, :author))
field(:threads, list_of(:thread), resolve: dataloader(CMS, :threads))
field(:threads, list_of(:thread_item), resolve: dataloader(CMS, :threads))
field(:categories, list_of(:category), resolve: dataloader(CMS, :categories))

@desc "total count of post contents"
Expand Down Expand Up @@ -443,7 +443,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
end

object :paged_threads do
field(:entries, list_of(:thread))
field(:entries, list_of(:thread_item))
pagination_fields()
end

Expand Down
10 changes: 5 additions & 5 deletions lib/groupher_server_web/schema/cms/mutations/comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do
@desc "write a comment"
field :create_article_comment, :article_comment do
# TODO use thread and force community pass-in
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:id, non_null(:id))
arg(:content, non_null(:string))
# arg(:mention_users, list_of(:ids))
Expand Down Expand Up @@ -82,7 +82,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do
field :create_comment, :comment do
# TODO use thread and force community pass-in
arg(:community, non_null(:string))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:id, non_null(:id))
arg(:body, non_null(:string))
arg(:mention_users, list_of(:ids))
Expand All @@ -97,7 +97,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do
@desc "update a comment"
field :update_comment, :comment do
arg(:id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:body, non_null(:string))

# TDOO: use a comment resolver
Expand All @@ -107,7 +107,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do

@desc "delete a comment"
field :delete_comment, :comment do
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:id, non_null(:id))

middleware(M.Authorize, :login)
Expand All @@ -123,7 +123,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Comment do
@desc "reply a exsiting comment"
field :reply_comment, :comment do
arg(:community, non_null(:string))
arg(:thread, non_null(:cms_thread), default_value: :post)
arg(:thread, non_null(:thread), default_value: :post)
arg(:id, non_null(:id))
arg(:body, non_null(:string))
arg(:mention_users, list_of(:ids))
Expand Down
8 changes: 4 additions & 4 deletions lib/groupher_server_web/schema/cms/mutations/community.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
end

@desc "create independent thread"
field :create_thread, :thread do
field :create_thread, :thread_item do
arg(:title, non_null(:string))
arg(:raw, non_null(:string))
arg(:index, :integer, default_value: 0)
Expand Down Expand Up @@ -131,7 +131,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
arg(:title, non_null(:string))
arg(:color, non_null(:rainbow_color_enum))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand All @@ -147,7 +147,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
# arg(:color, non_null(:rainbow_color_enum))
arg(:color, non_null(:rainbow_color_enum))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand All @@ -160,7 +160,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
field :delete_tag, :tag do
arg(:id, non_null(:id))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server_web/schema/cms/mutations/job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Job do
arg(:link_addr, :string)
arg(:copy_right, :string)

arg(:thread, :cms_thread, default_value: :job)
arg(:thread, :thread, default_value: :job)
arg(:tags, list_of(:ids))
arg(:mention_users, list_of(:ids))

Expand Down
8 changes: 4 additions & 4 deletions lib/groupher_server_web/schema/cms/mutations/operation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
arg(:tag_id, non_null(:id))
# community_id only use for passport check
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand All @@ -99,7 +99,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
arg(:id, non_null(:id))
arg(:tag_id, non_null(:id))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.PassportLoader, source: :community)
Expand All @@ -112,7 +112,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
field :set_community, :community do
arg(:id, non_null(:id))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.Passport, claim: "cms->t?.community.set")
Expand All @@ -123,7 +123,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
field :unset_community, :community do
arg(:id, non_null(:id))
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)

middleware(M.Authorize, :login)
middleware(M.Passport, claim: "cms->t?.community.unset")
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server_web/schema/cms/mutations/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do
arg(:link_addr, :string)
arg(:copy_right, :string)
arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :post)
arg(:thread, :thread, default_value: :post)
arg(:tags, list_of(:ids))
arg(:mention_users, list_of(:ids))

Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server_web/schema/cms/mutations/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Repo do
arg(:primary_language, non_null(:repo_lang_input))

arg(:community_id, non_null(:id))
arg(:thread, :cms_thread, default_value: :repo)
arg(:thread, :thread, default_value: :repo)
arg(:tags, list_of(:ids))

middleware(M.Authorize, :login)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule GroupherServer.Test.Mutation.Accounts.CollectFolder do

describe "[Accounts CollectFolder add/remove]" do
@query """
mutation($articleId: ID!, $folderId: ID!, $thread: CmsThread) {
mutation($articleId: ID!, $folderId: ID!, $thread: Thread) {
addToCollect(articleId: $articleId, folderId: $folderId, thread: $thread) {
id
title
Expand Down Expand Up @@ -154,7 +154,7 @@ defmodule GroupherServer.Test.Mutation.Accounts.CollectFolder do
end

@query """
mutation($articleId: ID!, $folderId: ID!, $thread: CmsThread) {
mutation($articleId: ID!, $folderId: ID!, $thread: Thread) {
removeFromCollect(articleId: $articleId, folderId: $folderId, thread: $thread) {
id
title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule GroupherServer.Test.Mutation.Account.Customization do
}
}
"""
@tag :wip2
@tag :wip3
test "PageSizeProof middleware should lint c11n displayDensity size", ~m(user)a do
user_conn = simu_conn(:user, user)
db_insert_multi(:post, 50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Job do

describe "[mutation job tag]" do
@set_tag_query """
mutation($thread: CmsThread!, $id: ID!, $tagId: ID! $communityId: ID!) {
mutation($thread: Thread!, $id: ID!, $tagId: ID! $communityId: ID!) {
setTag(thread: $thread, id: $id, tagId: $tagId, communityId: $communityId) {
id
title
Expand Down
6 changes: 3 additions & 3 deletions test/groupher_server_web/mutation/cms/articles/post_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do

describe "[mutation post comment]" do
@write_comment_query """
mutation($thread: CmsThread!, $id: ID!, $content: String!) {
mutation($thread: Thread!, $id: ID!, $content: String!) {
createArticleComment(thread: $thread,id: $id, content: $content) {
id
bodyHtml
Expand All @@ -515,7 +515,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do
end

@create_comment_query """
mutation($community: String!, $thread: CmsThread!, $id: ID!, $body: String!) {
mutation($community: String!, $thread: Thread!, $id: ID!, $body: String!) {
createComment(community: $community, thread: $thread,id: $id, body: $body) {
id
body
Expand All @@ -530,7 +530,7 @@ defmodule GroupherServer.Test.Mutation.Articles.Post do
end

@update_comment_query """
mutation($thread: CmsThread!, $id: ID!, $body: String!) {
mutation($thread: Thread!, $id: ID!, $body: String!) {
updateComment(thread: $thread,id: $id, body: $body) {
id
body
Expand Down
4 changes: 3 additions & 1 deletion test/groupher_server_web/mutation/cms/cms_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do

describe "[mutation cms tag]" do
@create_tag_query """
mutation($thread: CmsThread!, $title: String!, $color: RainbowColorEnum!, $communityId: ID!) {
mutation($thread: Thread!, $title: String!, $color: RainbowColorEnum!, $communityId: ID!) {
createTag(thread: $thread, title: $title, color: $color, communityId: $communityId) {
id
title
Expand Down Expand Up @@ -431,6 +431,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do
}
}
"""
@tag :wip2
test "auth user can create thread", ~m(user)a do
title = "post"
raw = "POST"
Expand All @@ -444,6 +445,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do
assert result["title"] == title
end

@tag :wip2
test "unauth user create thread fails", ~m(user_conn guest_conn)a do
title = "psot"
raw = "POST"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule GroupherServer.Test.Mutation.Comments.JobComment do

describe "[article comment CURD]" do
@write_comment_query """
mutation($thread: CmsThread!, $id: ID!, $content: String!) {
mutation($thread: Thread!, $id: ID!, $content: String!) {
createArticleComment(thread: $thread,id: $id, content: $content) {
id
bodyHtml
Expand Down
Loading