Skip to content

Commit

Permalink
Fix lint failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Sightler committed Jun 20, 2024
1 parent d79564e commit a23920f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ yarn.lock
.homebridge
.hoobs
.turbo
.gitattributes
2 changes: 1 addition & 1 deletion packages/homebridge-ring/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class Camera extends BaseDataAccessory<RingCamera> {
await Promise.race([
firstValueFrom(
this.device.onNewNotification.pipe(
filter((notification) => Boolean(notification.ding.image_uuid)),
filter((notification) => Boolean(notification.img.snapshot_uuid)),
),
),
// wait up to 2 seconds for the second notification
Expand Down
27 changes: 14 additions & 13 deletions packages/ring-client-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ export class RingApi extends Subscribed {
this.restClient._internalOnly_pushNotificationCredentials,
pushReceiver = new PushReceiver({
firebase: {
apiKey: "AIzaSyCv-hdFBmmdBBJadNy-TFwB-xN_H5m3Bk8",
projectId: "ring-17770",
messagingSenderId: "876313859327", // for Ring android app. 703521446232 for ring-site
appId: "1:876313859327:android:e10ec6ddb3c81f39"
apiKey: 'AIzaSyCv-hdFBmmdBBJadNy-TFwB-xN_H5m3Bk8',
projectId: 'ring-17770',
messagingSenderId: '876313859327', // for Ring android app. 703521446232 for ring-site
appId: '1:876313859327:android:e10ec6ddb3c81f39',
},
credentials,
debug: false,
Expand Down Expand Up @@ -276,7 +276,7 @@ export class RingApi extends Subscribed {
device: {
metadata: {
...this.restClient.baseSessionMetadata,
pn_dict_version: "2.0.0",
pn_dict_version: '2.0.0',
pn_service: 'fcm',
},
os: 'android',
Expand Down Expand Up @@ -311,14 +311,15 @@ export class RingApi extends Subscribed {
try {
const messageData = {} as any
for (const p in message.data) {
try {
// If it's a JSON string, parse it into an object
messageData[p] = JSONbig({ storeAsString: true }).parse(message.data[p] as string);
}
catch {
// Otherwise just assign the value directly
messageData[p] = message.data[p];
}
try {
// If it's a JSON string, parse it into an object
messageData[p] = JSONbig({ storeAsString: true }).parse(
message.data[p] as string,
)
} catch {
// Otherwise just assign the value directly
messageData[p] = message.data[p]
}
}

const notification = messageData as PushNotification
Expand Down
15 changes: 11 additions & 4 deletions packages/ring-client-api/ring-camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ export class RingCamera extends Subscribed {
onActiveNotifications = new BehaviorSubject<PushNotificationDing[]>([])
onDoorbellPressed = this.onNewNotification.pipe(
filter(
(notification) => notification.android_config.category === PushNotificationAction.Ding,
(notification) =>
notification.android_config.category === PushNotificationAction.Ding,
),
share(),
)
onMotionDetected = this.onActiveNotifications.pipe(
map((notifications) =>
notifications.some(
(notification) => notification.android_config.category === PushNotificationAction.Motion,
(notification) =>
notification.android_config.category ===
PushNotificationAction.Motion,
),
),
distinctUntilChanged(),
Expand Down Expand Up @@ -403,7 +406,9 @@ export class RingCamera extends Subscribed {

private removeDingById(idToRemove: string) {
const allActiveDings = this.activeNotifications,
otherDings = allActiveDings.filter(({ data }) => data.event.ding.id !== idToRemove)
otherDings = allActiveDings.filter(
({ data }) => data.event.ding.id !== idToRemove,
)

this.onActiveNotifications.next(otherDings)
}
Expand All @@ -418,7 +423,9 @@ export class RingCamera extends Subscribed {
dingId = notification.data.event.ding.id

this.onActiveNotifications.next(
activeDings.filter((d) => d.data.event.ding.id !== dingId).concat([notification]),
activeDings
.filter((d) => d.data.event.ding.id !== dingId)
.concat([notification]),
)
this.onNewNotification.next(notification)

Expand Down
5 changes: 4 additions & 1 deletion packages/ring-client-api/ring-intercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ export class RingIntercom {
processPushNotification(notification: PushNotification) {
if (notification.android_config.category === PushNotificationAction.Ding) {
this.onDing.next()
} else if (notification.android_config.category === PushNotificationAction.IntercomUnlock) {
} else if (
notification.android_config.category ===
PushNotificationAction.IntercomUnlock
) {
this.onUnlocked.next()
}
}
Expand Down
62 changes: 30 additions & 32 deletions packages/ring-client-api/ring-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,49 +1018,49 @@ export interface PushNotificationDing {
android_config: {
category: PushNotificationAction | string
body: string
},
}
analytics: {
server_correlation_id: string
server_id: "com.ring.pns" | string
subcategory: string
triggered_at: number
sent_at: number
referring_item_type: string
referring_item_id: string
server_id: 'com.ring.pns' | string
subcategory: string
triggered_at: number
sent_at: number
referring_item_type: string
referring_item_id: string
}
data: {
device: {
e2ee_enabled: boolean
id: number
kind: RingCameraKind
name: string
e2ee_enabled: boolean
id: number
kind: RingCameraKind
name: string
}
event: {
ding: {
id: string
created_at: string
subtype: 'motion' | 'ding' | 'human' | string
detection_type: NotificationDetectionType
}
eventito: {
type: string
timestamp: number
},
riid: string
is_sidewalk: boolean
live_session: {
active_streaming_profile: "rms" | string
default_audio_route: string
max_duration: number
}
id: string
created_at: string
subtype: 'motion' | 'ding' | 'human' | string
detection_type: NotificationDetectionType
}
eventito: {
type: string
timestamp: number
}
riid: string
is_sidewalk: boolean
live_session: {
active_streaming_profile: 'rms' | string
default_audio_route: string
max_duration: number
}
}
location: {
id: string
}
}
img: {
snapshot_uuid: string
}
snapshot_uuid: string
}
}

export interface PushNotificationAlarm {
Expand Down Expand Up @@ -1088,9 +1088,7 @@ export interface PushNotificationLowBattery {
action: PushNotificationAction.LowBattery
}

export type PushNotification =
| PushNotificationDing

export type PushNotification = PushNotificationDing

export interface SocketTicketResponse {
ticket: string
Expand Down

0 comments on commit a23920f

Please sign in to comment.