forked from nerdzeu/nerdz-api
/
project_post_relations.go
143 lines (113 loc) · 3.82 KB
/
project_post_relations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Copyright (C) 2016 Paolo Galeone <nessuno@nerdz.eu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package nerdz
// ProjectPostVote: implementing Vote interface
// Value returns the vote's value
func (vote *ProjectPostVote) Value() int8 {
return vote.Vote
}
// Sender returns the User that casted the vote
func (vote *ProjectPostVote) Sender() (user *User) {
user, _ = NewUser(vote.From)
return
}
// NumericSender returns the ID of the Sender
func (vote *ProjectPostVote) NumericSender() uint64 {
return vote.From
}
// Reference returns the reference of the vote
func (vote *ProjectPostVote) Reference() Reference {
post, _ := NewProjectPost(vote.Hpid)
return post
}
// NumericReference returns the numeric ID of the reference
func (vote *ProjectPostVote) NumericReference() uint64 {
return vote.Hpid
}
// ProjectPostBookmark: implementing Bookmark interface
// Sender returns the User that casted the bookmark
func (bookmark *ProjectPostBookmark) Sender() (user *User) {
user, _ = NewUser(bookmark.From)
return
}
// NumericSender returns the ID of the Sender
func (bookmark *ProjectPostBookmark) NumericSender() uint64 {
return bookmark.From
}
// Reference returns the reference of the bookmark
func (bookmark *ProjectPostBookmark) Reference() Reference {
post, _ := NewProjectPost(bookmark.Hpid)
return post
}
// NumericReference returns the numeric ID of the reference
func (bookmark *ProjectPostBookmark) NumericReference() uint64 {
return bookmark.Hpid
}
// ProjectPostLurk: implementing Lurk interface
// Sender returns the User that casted the lurk
func (lurk *ProjectPostLurk) Sender() (user *User) {
user, _ = NewUser(lurk.From)
return
}
// NumericSender returns the ID of the Sender
func (lurk *ProjectPostLurk) NumericSender() uint64 {
return lurk.From
}
// Reference returns the reference of the lurk
func (lurk *ProjectPostLurk) Reference() Reference {
post, _ := NewProjectPost(lurk.Hpid)
return post
}
// NumericReference returns the numeric ID of the reference
func (lurk *ProjectPostLurk) NumericReference() uint64 {
return lurk.Hpid
}
// ProjectPostLock: implementing Lock interface
// Sender returns the User that casted the lock
func (lock *ProjectPostLock) Sender() (user *User) {
user, _ = NewUser(lock.User)
return
}
// NumericSender returns the ID of the Sender
func (lock *ProjectPostLock) NumericSender() uint64 {
return lock.User
}
// Reference returns the reference of the lurk
func (lock *ProjectPostLock) Reference() Reference {
post, _ := NewProjectPost(lock.Hpid)
return post
}
// NumericReference returns the numeric ID of the reference
func (lock *ProjectPostLock) NumericReference() uint64 {
return lock.Hpid
}
// ProjectPostUserLock: implementing Lock interface
// Sender returns the User that casted the lock
func (lock *ProjectPostUserLock) Sender() (user *User) {
user, _ = NewUser(lock.From)
return
}
// NumericSender returns the ID of the Sender
func (lock *ProjectPostUserLock) NumericSender() uint64 {
return lock.From
}
// Reference returns the reference of the lurk
func (lock *ProjectPostUserLock) Reference() Reference {
post, _ := NewProjectPost(lock.Hpid)
return post
}
// NumericReference returns the numeric ID of the reference
func (lock *ProjectPostUserLock) NumericReference() uint64 {
return lock.Hpid
}