@@ -6,9 +6,12 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
6
6
import Helper.ErrorCode
7
7
# import ShortMaps
8
8
9
+ alias GroupherServer.CMS
10
+
9
11
alias Helper.ORM
12
+ alias Helper.SpecType , as: T
10
13
11
- alias GroupherServer. CMS. {
14
+ alias CMS . {
12
15
Community ,
13
16
CommunityWiki ,
14
17
CommunityCheatsheet
@@ -17,6 +20,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
17
20
@ doc """
18
21
get wiki
19
22
"""
23
+ @ spec get_wiki ( Community . t ( ) ) :: { :ok , CommunityWiki . t ( ) }
20
24
def get_wiki ( % Community { raw: raw } ) do
21
25
with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
22
26
{ :ok , wiki } <- ORM . find_by ( CommunityWiki , community_id: community . id ) do
@@ -30,6 +34,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
30
34
@ doc """
31
35
get cheatsheet
32
36
"""
37
+ @ spec get_cheatsheet ( Community . t ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
33
38
def get_cheatsheet ( % Community { raw: raw } ) do
34
39
with { :ok , community } <- ORM . find_by ( Community , raw: raw ) ,
35
40
{ :ok , wiki } <- ORM . find_by ( CommunityCheatsheet , community_id: community . id ) do
@@ -43,6 +48,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
43
48
@ doc """
44
49
sync wiki
45
50
"""
51
+ @ spec sync_github_content ( Community . t ( ) , atom ( ) , any ( ) ) :: { :ok , CommunityWiki . t ( ) }
46
52
def sync_github_content ( % Community { id: id } , :wiki , attrs ) do
47
53
with { :ok , community } <- ORM . find ( Community , id ) do
48
54
attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -54,6 +60,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
54
60
@ doc """
55
61
sync cheatsheet
56
62
"""
63
+ @ spec sync_github_content ( Community . t ( ) , atom ( ) , any ( ) ) :: { :ok , CommunityCheatsheet . t ( ) }
57
64
def sync_github_content ( % Community { id: id } , :cheatsheet , attrs ) do
58
65
with { :ok , community } <- ORM . find ( Community , id ) do
59
66
attrs = Map . merge ( attrs , % { community_id: community . id } )
@@ -65,10 +72,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
65
72
@ doc """
66
73
add contributor to exsit wiki contributors list
67
74
"""
75
+ @ spec add_contributor ( Community . t ( ) , T . github_contributor ( ) ) ::
76
+ { :ok , CommunityWiki } | T . gq_error ( )
68
77
def add_contributor ( % CommunityWiki { id: id } , contributor_attrs ) do
69
78
do_add_contributor ( CommunityWiki , id , contributor_attrs )
70
79
end
71
80
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 ( )
72
86
def add_contributor ( % CommunityCheatsheet { id: id } , contributor_attrs ) do
73
87
do_add_contributor ( CommunityCheatsheet , id , contributor_attrs )
74
88
end
0 commit comments