@@ -123,14 +123,55 @@ func (c *Comment) AfterDelete() {
123
123
}
124
124
}
125
125
126
+ // HTMLURL formats a URL-string to the issue-comment
127
+ func (c * Comment ) HTMLURL () string {
128
+ issue , err := GetIssueByID (c .IssueID )
129
+ if err != nil { // Silently dropping errors :unamused:
130
+ log .Error (4 , "GetIssueByID(%d): %v" , c .IssueID , err )
131
+ return ""
132
+ }
133
+ return fmt .Sprintf ("%s#issuecomment-%d" , issue .HTMLURL (), c .ID )
134
+ }
135
+
136
+ // IssueURL formats a URL-string to the issue
137
+ func (c * Comment ) IssueURL () string {
138
+ issue , err := GetIssueByID (c .IssueID )
139
+ if err != nil { // Silently dropping errors :unamused:
140
+ log .Error (4 , "GetIssueByID(%d): %v" , c .IssueID , err )
141
+ return ""
142
+ }
143
+
144
+ if issue .IsPull {
145
+ return ""
146
+ }
147
+ return issue .HTMLURL ()
148
+ }
149
+
150
+ // PRURL formats a URL-string to the pull-request
151
+ func (c * Comment ) PRURL () string {
152
+ issue , err := GetIssueByID (c .IssueID )
153
+ if err != nil { // Silently dropping errors :unamused:
154
+ log .Error (4 , "GetIssueByID(%d): %v" , c .IssueID , err )
155
+ return ""
156
+ }
157
+
158
+ if ! issue .IsPull {
159
+ return ""
160
+ }
161
+ return issue .HTMLURL ()
162
+ }
163
+
126
164
// APIFormat converts a Comment to the api.Comment format
127
165
func (c * Comment ) APIFormat () * api.Comment {
128
166
return & api.Comment {
129
- ID : c .ID ,
130
- Poster : c .Poster .APIFormat (),
131
- Body : c .Content ,
132
- Created : c .Created ,
133
- Updated : c .Updated ,
167
+ ID : c .ID ,
168
+ Poster : c .Poster .APIFormat (),
169
+ HTMLURL : c .HTMLURL (),
170
+ IssueURL : c .IssueURL (),
171
+ PRURL : c .PRURL (),
172
+ Body : c .Content ,
173
+ Created : c .Created ,
174
+ Updated : c .Updated ,
134
175
}
135
176
}
136
177
0 commit comments