2022-12-28 22:22:36 -05:00
|
|
|
package post
|
|
|
|
|
2022-12-30 01:44:31 -05:00
|
|
|
import (
|
2022-12-30 23:57:03 -05:00
|
|
|
"fmt"
|
2023-01-05 22:07:12 -05:00
|
|
|
"strings"
|
2022-12-30 02:05:48 -05:00
|
|
|
"time"
|
|
|
|
|
2023-01-05 22:07:12 -05:00
|
|
|
"github.com/mergestat/timediff"
|
2023-01-06 19:46:41 -05:00
|
|
|
"github.com/mrusme/neonmodem/models/author"
|
|
|
|
"github.com/mrusme/neonmodem/models/forum"
|
|
|
|
"github.com/mrusme/neonmodem/models/reply"
|
2022-12-30 01:44:31 -05:00
|
|
|
)
|
|
|
|
|
2022-12-28 22:22:36 -05:00
|
|
|
type Post struct {
|
|
|
|
ID string
|
|
|
|
|
|
|
|
Subject string
|
2022-12-30 01:44:31 -05:00
|
|
|
Body string
|
|
|
|
Type string // "post", "url"
|
|
|
|
|
|
|
|
Pinned bool
|
|
|
|
Closed bool
|
|
|
|
|
2022-12-30 02:05:48 -05:00
|
|
|
CreatedAt time.Time
|
|
|
|
LastCommentedAt time.Time
|
|
|
|
|
2022-12-30 01:44:31 -05:00
|
|
|
Author author.Author
|
|
|
|
|
2022-12-30 23:57:03 -05:00
|
|
|
Forum forum.Forum
|
|
|
|
|
2023-01-10 14:03:57 -05:00
|
|
|
TotalReplies int
|
|
|
|
CurrentRepliesStartIDX int
|
|
|
|
Replies []reply.Reply
|
2022-12-30 03:22:54 -05:00
|
|
|
|
2023-01-05 15:26:27 -05:00
|
|
|
URL string
|
|
|
|
|
2022-12-30 03:22:54 -05:00
|
|
|
SysIDX int
|
2022-12-28 22:22:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (post Post) FilterValue() string {
|
|
|
|
return post.Subject
|
|
|
|
}
|
|
|
|
|
|
|
|
func (post Post) Title() string {
|
|
|
|
return post.Subject
|
|
|
|
}
|
|
|
|
|
|
|
|
func (post Post) Description() string {
|
2022-12-30 23:57:03 -05:00
|
|
|
return fmt.Sprintf(
|
2023-01-05 22:07:12 -05:00
|
|
|
"by %s %s in %s",
|
2022-12-31 16:57:11 -05:00
|
|
|
post.Author.Name,
|
2023-01-05 22:07:12 -05:00
|
|
|
timediff.TimeDiff(post.CreatedAt.Local()),
|
|
|
|
strings.Title(post.Forum.Name),
|
2022-12-30 23:57:03 -05:00
|
|
|
)
|
2022-12-28 22:22:36 -05:00
|
|
|
}
|