@@ -4,6 +4,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4
4
"""
5
5
import Ecto.Query , warn: false
6
6
import Helper.ErrorCode
7
+ import Helper.CommonTypes
7
8
# import ShortMaps
8
9
9
10
alias Helper.ORM
@@ -17,6 +18,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
17
18
@ doc """
18
19
get wiki
19
20
"""
21
+ @ spec get_wiki ( Community . t ( ) ) :: { :ok , CommunityWiki . t ( ) }
20
22
def get_wiki ( % Community { raw: raw } ) do
21
23
with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
22
24
{ :ok , wiki } <- ORM . find_by ( CommunityWiki , community_id: community . id ) do
@@ -30,6 +32,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
30
32
@ doc """
31
33
get cheatsheet
32
34
"""
35
+ @ spec get_cheatsheet ( Community . t ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
33
36
def get_cheatsheet ( % Community { raw: raw } ) do
34
37
with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
35
38
{ :ok , wiki } <- ORM . find_by ( CommunityCheatsheet , community_id: community . id ) do
@@ -43,6 +46,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
43
46
@ doc """
44
47
sync wiki
45
48
"""
49
+ @ spec sync_github_content ( Community . t ( ) , atom ) :: { :ok , CommunityWiki . t ( ) }
46
50
def sync_github_content ( % Community { id: id } , :wiki , attrs ) do
47
51
with { :ok , community } <- ORM . find ( Community , id ) do
48
52
attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -54,6 +58,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
54
58
@ doc """
55
59
sync cheatsheet
56
60
"""
61
+ @ spec sync_github_content ( Community . t ( ) , atom ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
57
62
def sync_github_content ( % Community { id: id } , :cheatsheet , attrs ) do
58
63
with { :ok , community } <- ORM . find ( Community , id ) do
59
64
attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -65,10 +70,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
65
70
@ doc """
66
71
add contributor to exsit wiki contributors list
67
72
"""
73
+ @ spec add_contributor ( Community . t ( ) , github_contributor ( ) ) ::
74
+ { :ok , CommunityWiki } | custom_error ( )
68
75
def add_contributor ( % CommunityWiki { id: id } , contributor_attrs ) do
69
76
do_add_contributor ( CommunityWiki , id , contributor_attrs )
70
77
end
71
78
79
+ @ doc """
80
+ add contributor to exsit cheatsheet contributors list
81
+ """
82
+ @ spec add_contributor ( Community . t ( ) , github_contributor ( ) ) ::
83
+ { :ok , CommunityCheatsheet } | custom_error ( )
72
84
def add_contributor ( % CommunityCheatsheet { id: id } , contributor_attrs ) do
73
85
do_add_contributor ( CommunityCheatsheet , id , contributor_attrs )
74
86
end
0 commit comments