@@ -4,6 +4,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
44 """
55 import Ecto.Query , warn: false
66 import Helper.ErrorCode
7+ import Helper.CommonTypes
78 # import ShortMaps
89
910 alias Helper.ORM
@@ -17,6 +18,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
1718 @ doc """
1819 get wiki
1920 """
21+ @ spec get_wiki ( Community . t ( ) ) :: { :ok , CommunityWiki . t ( ) }
2022 def get_wiki ( % Community { raw: raw } ) do
2123 with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
2224 { :ok , wiki } <- ORM . find_by ( CommunityWiki , community_id: community . id ) do
@@ -30,6 +32,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
3032 @ doc """
3133 get cheatsheet
3234 """
35+ @ spec get_cheatsheet ( Community . t ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
3336 def get_cheatsheet ( % Community { raw: raw } ) do
3437 with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
3538 { :ok , wiki } <- ORM . find_by ( CommunityCheatsheet , community_id: community . id ) do
@@ -43,6 +46,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4346 @ doc """
4447 sync wiki
4548 """
49+ @ spec sync_github_content ( Community . t ( ) , atom ) :: { :ok , CommunityWiki . t ( ) }
4650 def sync_github_content ( % Community { id: id } , :wiki , attrs ) do
4751 with { :ok , community } <- ORM . find ( Community , id ) do
4852 attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -54,6 +58,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
5458 @ doc """
5559 sync cheatsheet
5660 """
61+ @ spec sync_github_content ( Community . t ( ) , atom ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
5762 def sync_github_content ( % Community { id: id } , :cheatsheet , attrs ) do
5863 with { :ok , community } <- ORM . find ( Community , id ) do
5964 attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -65,10 +70,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
6570 @ doc """
6671 add contributor to exsit wiki contributors list
6772 """
73+ @ spec add_contributor ( Community . t ( ) , github_contributor ( ) ) ::
74+ { :ok , CommunityWiki } | custom_error ( )
6875 def add_contributor ( % CommunityWiki { id: id } , contributor_attrs ) do
6976 do_add_contributor ( CommunityWiki , id , contributor_attrs )
7077 end
7178
79+ @ doc """
80+ add contributor to exsit cheatsheet contributors list
81+ """
82+ @ spec add_contributor ( Community . t ( ) , github_contributor ( ) ) ::
83+ { :ok , CommunityCheatsheet } | custom_error ( )
7284 def add_contributor ( % CommunityCheatsheet { id: id } , contributor_attrs ) do
7385 do_add_contributor ( CommunityCheatsheet , id , contributor_attrs )
7486 end
0 commit comments