1
+ package com .lopcode .bluesky .jetstream .model ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import com .fasterxml .jackson .annotation .JsonSubTypes ;
5
+ import com .fasterxml .jackson .annotation .JsonTypeInfo ;
6
+ import com .fasterxml .jackson .databind .JsonNode ;
7
+
8
+ @ JsonTypeInfo (
9
+ use = JsonTypeInfo .Id .NAME ,
10
+ include = JsonTypeInfo .As .EXISTING_PROPERTY ,
11
+ defaultImpl = JetstreamEvent .Unknown .class ,
12
+ property = "kind" ,
13
+ visible = true
14
+ )
15
+ @ JsonSubTypes ({
16
+ @ JsonSubTypes .Type (value = JetstreamEvent .Commit .class , name = "commit" ),
17
+ @ JsonSubTypes .Type (value = JetstreamEvent .Identity .class , name = "identity" ),
18
+ @ JsonSubTypes .Type (value = JetstreamEvent .Account .class , name = "account" )
19
+ })
20
+ public class JetstreamEvent {
21
+ @ JsonProperty ("did" )
22
+ String did ;
23
+ @ JsonProperty ("kind" )
24
+ String kind ;
25
+ @ JsonProperty ("time_us" )
26
+ long unixTimeMicroseconds ;
27
+
28
+ public static class Commit extends JetstreamEvent {
29
+ @ JsonProperty ("commit" )
30
+ CommitInfo commit ;
31
+
32
+ @ Override
33
+ public String toString () {
34
+ return "Commit{" +
35
+ "commit=" + commit +
36
+ ", did='" + did + '\'' +
37
+ ", kind='" + kind + '\'' +
38
+ ", unixTimeMicroseconds=" + unixTimeMicroseconds +
39
+ '}' ;
40
+ }
41
+ }
42
+
43
+ public static class CommitInfo {
44
+ @ JsonProperty ("rev" )
45
+ String rev ;
46
+ @ JsonProperty ("rkey" )
47
+ String rkey ;
48
+ @ JsonProperty ("operation" )
49
+ String operation ;
50
+ @ JsonProperty ("collection" )
51
+ String collection ;
52
+ @ JsonProperty ("cid" )
53
+ String cid ;
54
+ @ JsonProperty ("record" )
55
+ JsonNode record ; // todo: model atproto records
56
+
57
+ @ Override
58
+ public String toString () {
59
+ return "CommitInfo{" +
60
+ "rev='" + rev + '\'' +
61
+ ", rkey='" + rkey + '\'' +
62
+ ", operation='" + operation + '\'' +
63
+ ", collection='" + collection + '\'' +
64
+ ", cid='" + cid + '\'' +
65
+ ", record=" + record +
66
+ '}' ;
67
+ }
68
+ }
69
+
70
+ public static class Identity extends JetstreamEvent {
71
+ @ JsonProperty ("identity" )
72
+ IdentityInfo identity ;
73
+
74
+ @ Override
75
+ public String toString () {
76
+ return "Identity{" +
77
+ "identity=" + identity +
78
+ ", did='" + did + '\'' +
79
+ ", kind='" + kind + '\'' +
80
+ ", unixTimeMicroseconds=" + unixTimeMicroseconds +
81
+ '}' ;
82
+ }
83
+ }
84
+
85
+ public static class IdentityInfo {
86
+ @ JsonProperty ("did" )
87
+ String did ;
88
+ @ JsonProperty ("handle" )
89
+ String handle ;
90
+ @ JsonProperty ("seq" )
91
+ Long seq ;
92
+ @ JsonProperty ("time" )
93
+ String time ;
94
+
95
+ @ Override
96
+ public String toString () {
97
+ return "IdentityInfo{" +
98
+ "did='" + did + '\'' +
99
+ ", handle='" + handle + '\'' +
100
+ ", seq=" + seq +
101
+ ", time='" + time + '\'' +
102
+ '}' ;
103
+ }
104
+ }
105
+
106
+ public static class Account extends JetstreamEvent {
107
+ @ JsonProperty ("account" )
108
+ AccountInfo account ;
109
+
110
+ @ Override
111
+ public String toString () {
112
+ return "Account{" +
113
+ "account=" + account +
114
+ '}' ;
115
+ }
116
+ }
117
+
118
+ public static class AccountInfo {
119
+ @ JsonProperty ("active" )
120
+ boolean active ;
121
+ @ JsonProperty ("did" )
122
+ String did ;
123
+ @ JsonProperty ("seq" )
124
+ Long seq ;
125
+ @ JsonProperty ("time" )
126
+ String time ;
127
+ @ JsonProperty ("status" )
128
+ String status ;
129
+
130
+ @ Override
131
+ public String toString () {
132
+ return "AccountInfo{" +
133
+ "active=" + active +
134
+ ", did='" + did + '\'' +
135
+ ", seq=" + seq +
136
+ ", time='" + time + '\'' +
137
+ ", status='" + status + '\'' +
138
+ '}' ;
139
+ }
140
+ }
141
+
142
+ public static class Unknown extends JetstreamEvent {
143
+ @ Override
144
+ public String toString () {
145
+ return "Unknown{" +
146
+ "did='" + did + '\'' +
147
+ ", kind='" + kind + '\'' +
148
+ ", unixTimeMicroseconds=" + unixTimeMicroseconds +
149
+ '}' ;
150
+ }
151
+ }
152
+ }
0 commit comments