@@ -6,9 +6,12 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
66 import Helper.ErrorCode
77 # import ShortMaps
88
9+ alias GroupherServer.CMS
10+
911 alias Helper.ORM
12+ alias Helper.SpecType , as: T
1013
11- alias GroupherServer. CMS. {
14+ alias CMS . {
1215 Community ,
1316 CommunityWiki ,
1417 CommunityCheatsheet
@@ -17,6 +20,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
1720 @ doc """
1821 get wiki
1922 """
23+ @ spec get_wiki ( Community . t ( ) ) :: { :ok , CommunityWiki . t ( ) }
2024 def get_wiki ( % Community { raw: raw } ) do
2125 with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
2226 { :ok , wiki } <- ORM . find_by ( CommunityWiki , community_id: community . id ) do
@@ -30,6 +34,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
3034 @ doc """
3135 get cheatsheet
3236 """
37+ @ spec get_cheatsheet ( Community . t ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
3338 def get_cheatsheet ( % Community { raw: raw } ) do
3439 with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
3540 { :ok , wiki } <- ORM . find_by ( CommunityCheatsheet , community_id: community . id ) do
@@ -43,6 +48,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4348 @ doc """
4449 sync wiki
4550 """
51+ @ spec sync_github_content ( Community . t ( ) , atom ( ) , any ( ) ) :: { :ok , CommunityWiki . t ( ) }
4652 def sync_github_content ( % Community { id: id } , :wiki , attrs ) do
4753 with { :ok , community } <- ORM . find ( Community , id ) do
4854 attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -54,6 +60,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
5460 @ doc """
5561 sync cheatsheet
5662 """
63+ @ spec sync_github_content ( Community . t ( ) , atom ( ) , any ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
5764 def sync_github_content ( % Community { id: id } , :cheatsheet , attrs ) do
5865 with { :ok , community } <- ORM . find ( Community , id ) do
5966 attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -65,10 +72,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
6572 @ doc """
6673 add contributor to exsit wiki contributors list
6774 """
75+ @ spec add_contributor ( Community . t ( ) , T . github_contributor ( ) ) ::
76+ { :ok , CommunityWiki } | T . gq_error ( )
6877 def add_contributor ( % CommunityWiki { id: id } , contributor_attrs ) do
6978 do_add_contributor ( CommunityWiki , id , contributor_attrs )
7079 end
7180
81+ @ doc """
82+ add contributor to exsit cheatsheet contributors list
83+ """
84+ @ spec add_contributor ( Community . t ( ) , T . github_contributor ( ) ) ::
85+ { :ok , CommunityCheatsheet } | T . gq_error ( )
7286 def add_contributor ( % CommunityCheatsheet { id: id } , contributor_attrs ) do
7387 do_add_contributor ( CommunityCheatsheet , id , contributor_attrs )
7488 end
0 commit comments