This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Image is a public photo already attached to a site post.
|
||||
type Image struct {
|
||||
URL string
|
||||
Description string
|
||||
}
|
||||
|
||||
// PostEvent is a Discord-free snapshot of a site post after a successful write.
|
||||
type PostEvent struct {
|
||||
PostID string
|
||||
RootID string
|
||||
ParentID string
|
||||
Title string
|
||||
Body string
|
||||
City string
|
||||
AuthorID string
|
||||
AuthorName string
|
||||
AuthorRole string
|
||||
Images []Image
|
||||
Permalink string
|
||||
}
|
||||
|
||||
// PostCreated is emitted after a successful site create.
|
||||
type PostCreated struct {
|
||||
PostEvent
|
||||
}
|
||||
|
||||
// PostUpdated is emitted after a successful site edit.
|
||||
type PostUpdated struct {
|
||||
PostEvent
|
||||
}
|
||||
|
||||
// Permalink builds /questions/{root}#post-{id}, prefixed by baseURL when set.
|
||||
func Permalink(baseURL, rootID, postID string) string {
|
||||
path := "/questions/" + url.PathEscape(rootID) + "#post-" + url.PathEscape(postID)
|
||||
base := strings.TrimRight(strings.TrimSpace(baseURL), "/")
|
||||
if base == "" {
|
||||
return path
|
||||
}
|
||||
return base + path
|
||||
}
|
||||
Reference in New Issue
Block a user