-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage_change.go
66 lines (62 loc) · 2 KB
/
page_change.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 eventstream
import (
"encoding/json"
"time"
)
// PageChange event scheme struct
type PageChange struct {
ID []Info
Data struct {
Schema string `json:"$schema"`
Meta Meta `json:"meta"`
Performer struct {
UserText string `json:"user_text"`
UserGroups []string `json:"groups"`
UserIsBot bool `json:"is_bot"`
UserID int `json:"user_id"`
UserRegistrationDt time.Time `json:"registration_dt"`
UserEditCount int `json:"edit_count"`
} `json:"performer"`
Dt time.Time `json:"dt"`
ChangelogKind string `json:"changelog_kind"`
PageChangeKind string `json:"page_change_kind"`
Page struct {
PageID int `json:"page_id"`
PageTitle string `json:"page_title"`
PageNamespace int `json:"namespace_id"`
PageIsRedirect bool `json:"is_redirect"`
} `json:"page"`
Revision struct {
RevID int `json:"rev_id"`
RevDt time.Time `json:"rev_dt"`
Comment string `json:"comment"`
ContentSlots struct {
Main struct {
ContentFormat string `json:"content_format"`
ContentModel string `json:"content_model"`
} `json:"main"`
} `json:"content_slots"`
IsCommentVisible bool `json:"is_comment_visible"`
IsContentVisible bool `json:"is_content_visible"`
IsEditorVisible bool `json:"is_editor_visible"`
IsMinorEdit bool `json:"is_minor_edit"`
RevParentID int `json:"rev_parent_id"`
RevSha1 string `json:"rev_sha1"`
RevSize int `json:"rev_size"`
} `json:"revision"`
PriorState struct {
Page struct {
PageTitle string `json:"page_title"`
PageNamespace int `json:"namespace_id"`
} `json:"page"`
} `json:"prior_state"`
Database string `json:"wiki_id"`
}
}
func (rc *PageChange) timestamp() time.Time {
return rc.Data.Meta.Dt
}
func (rc *PageChange) unmarshal(evt *Event) error {
rc.ID = evt.ID
return json.Unmarshal(evt.Data, &rc.Data)
}