/
types.go
66 lines (54 loc) · 1.57 KB
/
types.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
package discord
import (
"fmt"
"github.com/status-im/status-go/protocol/protobuf"
)
type ErrorType uint
const (
NoError ErrorType = iota
Warning
Error
)
type MessageType string
const (
MessageTypeDefault MessageType = "Default"
MessageTypeReply MessageType = "Reply"
)
type Channel struct {
ID string `json:"id"`
CategoryName string `json:"category"`
CategoryID string `json:"categoryId"`
Name string `json:"name"`
Description string `json:"topic"`
FilePath string `json:"filePath"`
}
type Category struct {
ID string `json:"id"`
Name string `json:"name"`
}
type ExportedData struct {
Channel Channel `json:"channel"`
Messages []*protobuf.DiscordMessage `json:"messages"`
}
type ExtractedData struct {
Categories map[string]*Category
ExportedData []*ExportedData
OldestMessageTimestamp int
}
type ImportError struct {
// This code is used to distinguish between errors
// that are considered "criticial" and those that are not.
//
// Critical errors are the ones that prevent the imported community
// from functioning properly. For example, if the creation of the community
// or its categories and channels fails, this is a critical error.
//
// Non-critical errors are the ones that would not prevent the imported
// community from functioning. For example, if the channel data to be imported
// has no messages, or is not parsable.
Code ErrorType `json:"code"`
Message string `json:"message"`
}
func (d ImportError) Error() string {
return fmt.Sprintf("%d: %s", d.Code, d.Message)
}