-
Notifications
You must be signed in to change notification settings - Fork 44
/
models.go
85 lines (75 loc) · 1.85 KB
/
models.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
package v2
// DONTCOVER
import (
"time"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)
// NewPost allows to build a new Post instance
func NewPost(
subspaceID uint64,
sectionID uint32,
id uint64,
externalID string,
text string,
author string,
conversationID uint64,
entities *Entities,
referencedPosts []PostReference,
replySetting ReplySetting,
creationDate time.Time,
lastEditedDate *time.Time,
) Post {
return Post{
SubspaceID: subspaceID,
SectionID: sectionID,
ID: id,
ExternalID: externalID,
Text: text,
Entities: entities,
Author: author,
ConversationID: conversationID,
ReferencedPosts: referencedPosts,
ReplySettings: replySetting,
CreationDate: creationDate,
LastEditedDate: lastEditedDate,
}
}
// NewEntities returns a new Entities instance
func NewEntities(hashtags []Tag, mentions []Tag, urls []Url) *Entities {
return &Entities{
Hashtags: hashtags,
Mentions: mentions,
Urls: urls,
}
}
// NewTag returns a new Tag instance
func NewTag(start, end uint64, tag string) Tag {
return Tag{
Start: start,
End: end,
Tag: tag,
}
}
// NewURL returns a new Url instance
func NewURL(start, end uint64, url, displayURL string) Url {
return Url{
Start: start,
End: end,
Url: url,
DisplayUrl: displayURL,
}
}
// NewPostReference returns a new PostReference instance
func NewPostReference(referenceType PostReferenceType, postID uint64, position uint64) PostReference {
return PostReference{
Type: referenceType,
PostID: postID,
Position: position,
}
}
type AttachmentContent interface{}
// UnpackInterfaces implements codectypes.UnpackInterfacesMessage
func (a *Attachment) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var content AttachmentContent
return unpacker.UnpackAny(a.Content, &content)
}