generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathissue.go
50 lines (41 loc) · 1.11 KB
/
issue.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
package main
import (
"fmt"
"time"
"github.com/mattermost/mattermost/server/public/model"
)
// Issue represents a Todo issue
type Issue struct {
ID string `json:"id"`
Message string `json:"message"`
Description string `json:"description,omitempty"`
CreateAt int64 `json:"create_at"`
PostID string `json:"post_id"`
}
// ExtendedIssue extends the information on Issue to be used on the front-end
type ExtendedIssue struct {
Issue
ForeignUser string `json:"user"`
ForeignList string `json:"list"`
ForeignPosition int `json:"position"`
}
func newIssue(message string, description, postID string) *Issue {
return &Issue{
ID: model.NewId(),
CreateAt: model.GetMillis(),
Message: message,
Description: description,
PostID: postID,
}
}
func issuesListToString(issues []*ExtendedIssue) string {
if len(issues) == 0 {
return "Nothing to do!"
}
str := "\n\n"
for _, issue := range issues {
createAt := time.Unix(issue.CreateAt/1000, 0)
str += fmt.Sprintf("* %s\n * (%s)\n", issue.Message, createAt.Format("January 2, 2006 at 15:04"))
}
return str
}