@@ -35,78 +35,106 @@ export function connect(APP_ID, APP_SECRET, emitter) {
35
35
} ,
36
36
37
37
received ( { type, payload } ) {
38
- if ( type === "world" ) {
39
- emitter . emit ( "participant-room-data-reset" ) ;
40
- // Parse the initial dump of world data
41
- if ( hasSeenWorldDataWithoutReconnect )
42
- // This is just a bit confusing but not that problematic
43
- console . error ( "Saw world data twice without a reconnect" ) ;
44
- hasSeenWorldDataWithoutReconnect = true ;
45
- payload . entities . forEach ( ( entity ) => {
46
- const { type, name, zoom_user_display_name } = entity ;
47
- if ( type === "Bot" && name ?. match ( / r c v e r s e / i) ) {
48
- console . error ( `Uncleaned bot found: ${ entity . id } ` , entity ) ;
49
- } else if ( type === "Note" ) {
50
- const { id, note_text, note_updated_at } = entity ;
38
+ try {
39
+ if ( type === "world" ) {
40
+ emitter . emit ( "participant-room-data-reset" ) ;
41
+ // Parse the initial dump of world data
42
+ if ( hasSeenWorldDataWithoutReconnect )
43
+ // This is just a bit confusing but not that problematic
44
+ console . error ( "Saw world data twice without a reconnect" ) ;
45
+ hasSeenWorldDataWithoutReconnect = true ;
46
+ payload . entities . forEach ( ( entity ) => {
47
+ const { type, name, zoom_user_display_name } = entity ;
48
+ if ( type === "Bot" && name ?. match ( / r c v e r s e / i) ) {
49
+ console . error ( `Uncleaned bot found: ${ entity . id } ` , entity ) ;
50
+ } else if ( type === "Note" ) {
51
+ const { id, note_text, note_updated_at } = entity ;
52
+ emitter . emit ( "room-note-data" , {
53
+ id : String ( id ) ,
54
+ content : note_text ,
55
+ updatedTimestamp : note_updated_at ,
56
+ } ) ;
57
+ } else if ( type === "Avatar" && zoom_user_display_name !== null ) {
58
+ const {
59
+ person_name,
60
+ image_path,
61
+ last_seen_at,
62
+ rc_hub_visit_today,
63
+ flair,
64
+ } = entity ;
65
+
66
+ const lastSeenMillis = new Date ( last_seen_at ) . getTime ( ) ;
67
+ const millisSinceLastSeen = Date . now ( ) - lastSeenMillis ;
68
+ const hourInMillis = 1000 * 60 * 60 ;
69
+ // If we haven't been seen in one hour and 15 minutes
70
+ // TODO: Contact James Porter to attempt to fix the bug where people
71
+ // remain in the zoom room forever
72
+ // NOTE: For groups like Music Consumption Group, that hang in Zoom
73
+ // for many many hours, we DO want the long "since last seen"
74
+ // but for the bug where people stay in the channel forever, we don't
75
+ // Tricky tricky.
76
+ if ( millisSinceLastSeen > 5 * hourInMillis ) return ;
77
+
78
+ emitter . emit ( "participant-room-data" , {
79
+ participantName : person_name ,
80
+ roomName : zoom_user_display_name ,
81
+ faceMarkerImagePath : image_path ,
82
+ inTheHub : rc_hub_visit_today ,
83
+ lastBatch : flair ,
84
+ } ) ;
85
+ } else if (
86
+ type === "UnknownAvatar" &&
87
+ zoom_user_display_name !== null
88
+ ) {
89
+ const { person_name, image_path } = entity ;
90
+
91
+ emitter . emit ( "participant-room-data" , {
92
+ participantName : person_name ,
93
+ roomName : zoom_user_display_name ,
94
+ faceMarkerImagePath : image_path ,
95
+ inTheHub : false ,
96
+ lastBatch : "" ,
97
+ } ) ;
98
+ }
99
+ } ) ;
100
+ } else if ( type === "entity" ) {
101
+ const { type } = payload ;
102
+ if ( type === "Note" ) {
103
+ const { id, note_text, note_updated_at } = payload ;
51
104
emitter . emit ( "room-note-data" , {
52
105
id : String ( id ) ,
53
106
content : note_text ,
54
107
updatedTimestamp : note_updated_at ,
55
108
} ) ;
56
- } else if ( type === "Avatar" && zoom_user_display_name !== null ) {
109
+ } else if ( type === "Avatar" ) {
57
110
const {
58
111
person_name,
112
+ zoom_user_display_name,
59
113
image_path,
60
- last_seen_at,
61
114
rc_hub_visit_today,
62
115
flair,
63
- } = entity ;
64
- const lastSeenMillis = new Date ( last_seen_at ) . getTime ( ) ;
65
- const millisSinceLastSeen = Date . now ( ) - lastSeenMillis ;
66
- const hourInMillis = 1000 * 60 * 60 ;
67
- // If we haven't been seen in one hour and 15 minutes
68
- // TODO: Contact James Porter to attempt to fix the bug where people
69
- // remain in the zoom room forever
70
- // NOTE: For groups like Music Consumption Group, that hang in Zoom
71
- // for many many hours, we DO want the long "since last seen"
72
- // but for the bug where people stay in the channel forever, we don't
73
- // Tricky tricky.
74
- if ( millisSinceLastSeen > 5 * hourInMillis ) return ;
75
-
116
+ } = payload ;
76
117
emitter . emit ( "participant-room-data" , {
77
118
participantName : person_name ,
78
119
roomName : zoom_user_display_name ,
79
120
faceMarkerImagePath : image_path ,
80
121
inTheHub : rc_hub_visit_today ,
81
122
lastBatch : flair ,
82
123
} ) ;
124
+ } else if ( type === "UnknownAvatar" ) {
125
+ const { person_name, image_path, zoom_user_display_name } = payload ;
126
+
127
+ emitter . emit ( "participant-room-data" , {
128
+ participantName : person_name ,
129
+ roomName : zoom_user_display_name ,
130
+ faceMarkerImagePath : image_path ,
131
+ inTheHub : false ,
132
+ lastBatch : "" ,
133
+ } ) ;
83
134
}
84
- } ) ;
85
- } else if ( type === "entity" ) {
86
- const { type } = payload ;
87
- if ( type === "Note" ) {
88
- const { id, note_text, note_updated_at } = payload ;
89
- emitter . emit ( "room-note-data" , {
90
- id : String ( id ) ,
91
- content : note_text ,
92
- updatedTimestamp : note_updated_at ,
93
- } ) ;
94
- } else if ( type === "Avatar" ) {
95
- const {
96
- person_name,
97
- zoom_user_display_name,
98
- image_path,
99
- rc_hub_visit_today,
100
- flair,
101
- } = payload ;
102
- emitter . emit ( "participant-room-data" , {
103
- participantName : person_name ,
104
- roomName : zoom_user_display_name ,
105
- faceMarkerImagePath : image_path ,
106
- inTheHub : rc_hub_visit_today ,
107
- lastBatch : flair ,
108
- } ) ;
109
135
}
136
+ } catch ( error ) {
137
+ console . error ( "ActionCable couldn't handle an error:" , error ) ;
110
138
}
111
139
} ,
112
140
} ) ;
0 commit comments