+14
-14
apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts
+14
-14
apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts
···
23
23
Effect.catchAll((err) => {
24
24
console.error(err);
25
25
return Effect.succeed({});
26
-
}),
26
+
})
27
27
);
28
28
server.app.rocksky.spotify.getCurrentlyPlaying({
29
29
auth: ctx.authVerifier,
···
54
54
.where(
55
55
or(
56
56
eq(tables.users.did, params.actor || did),
57
-
eq(tables.users.handle, params.actor || did),
58
-
),
57
+
eq(tables.users.handle, params.actor || did)
58
+
)
59
59
)
60
60
.execute()
61
61
.then((users) => ({ user: users[0], ctx, params, did })),
···
90
90
.from(tables.spotifyAccounts)
91
91
.leftJoin(
92
92
tables.users,
93
-
eq(tables.users.id, tables.spotifyAccounts.userId),
93
+
eq(tables.users.id, tables.spotifyAccounts.userId)
94
94
)
95
95
.where(
96
96
or(
97
97
eq(tables.users.did, params.actor || did),
98
-
eq(tables.users.handle, params.actor || did),
99
-
),
98
+
eq(tables.users.handle, params.actor || did)
99
+
)
100
100
)
101
101
.execute()
102
102
.then(([results]) => ({
···
129
129
Match.value(cached).pipe(
130
130
Match.when(null, () => ({})),
131
131
Match.when(undefined, () => ({})),
132
-
Match.orElse(() => JSON.parse(cached)),
133
-
),
132
+
Match.orElse(() => JSON.parse(cached))
133
+
)
134
134
)
135
135
.then((cached) => [cached, ctx, user]),
136
136
catch: (error) =>
···
143
143
try: async () => {
144
144
const sha256 = createHash("sha256")
145
145
.update(
146
-
`${track.item.name} - ${track.item.artists.map((x) => x.name).join(", ")} - ${track.item.album.name}`.toLowerCase(),
146
+
`${track.item.name} - ${track.item.artists.map((x) => x.name).join(", ")} - ${track.item.album.name}`.toLowerCase()
147
147
)
148
148
.digest("hex");
149
149
const [record] = await ctx.db
···
156
156
.from(tables.lovedTracks)
157
157
.leftJoin(
158
158
tables.tracks,
159
-
eq(tables.lovedTracks.trackId, tables.tracks.id),
159
+
eq(tables.lovedTracks.trackId, tables.tracks.id)
160
160
)
161
161
.leftJoin(tables.users, eq(tables.lovedTracks.userId, tables.users.id))
162
162
.where(
163
-
and(eq(tables.tracks.sha256, sha256), eq(tables.users.did, user.did)),
163
+
and(eq(tables.tracks.sha256, sha256), eq(tables.users.did, user.did))
164
164
)
165
165
.execute()
166
166
.then((results) =>
167
167
Match.value(track).pipe(
168
168
Match.when(
169
169
(t) => !Object.keys(t).length,
170
-
() => ({}),
170
+
() => ({})
171
171
),
172
172
Match.orElse(() => ({
173
173
...track,
···
175
175
artistUri: record?.artistUri,
176
176
albumUri: record?.albumUri,
177
177
liked: results.length > 0,
178
-
})),
179
-
),
178
+
}))
179
+
)
180
180
);
181
181
},
182
182
catch: (error) => new Error(`Failed to retrieve URI and likes: ${error}`),
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/next.ts
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/next.ts
···
23
23
Effect.catchAll((err) => {
24
24
console.error(err);
25
25
return Effect.succeed({});
26
-
}),
26
+
})
27
27
);
28
28
server.app.rocksky.spotify.next({
29
29
auth: ctx.authVerifier,
···
72
72
.where(eq(tables.spotifyTokens.userId, user.id))
73
73
.execute()
74
74
.then(([spotifyToken]) =>
75
-
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY),
75
+
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY)
76
76
)
77
77
.then((refreshToken) => ({
78
78
user,
···
105
105
client_secret: env.SPOTIFY_CLIENT_SECRET,
106
106
}),
107
107
})
108
-
.then((res) => res.json())
108
+
.then((res) => res.json() as Promise<{ access_token: string }>)
109
109
.then((data) => data.access_token),
110
110
catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`),
111
111
});
+3
-4
apps/api/src/xrpc/app/rocksky/spotify/pause.ts
+3
-4
apps/api/src/xrpc/app/rocksky/spotify/pause.ts
···
23
23
Effect.catchAll((err) => {
24
24
console.error(err);
25
25
return Effect.succeed({});
26
-
}),
26
+
})
27
27
);
28
28
server.app.rocksky.spotify.pause({
29
29
auth: ctx.authVerifier,
···
72
72
.where(eq(tables.spotifyTokens.userId, user.id))
73
73
.execute()
74
74
.then(([spotifyToken]) =>
75
-
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY),
75
+
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY)
76
76
)
77
77
.then((refreshToken) => ({
78
78
user,
···
86
86
87
87
const withSpotifyToken = ({
88
88
refreshToken,
89
-
ctx,
90
89
}: {
91
90
refreshToken: string;
92
91
ctx: Context;
···
105
104
client_secret: env.SPOTIFY_CLIENT_SECRET,
106
105
}),
107
106
})
108
-
.then((res) => res.json())
107
+
.then((res) => res.json() as Promise<{ access_token: string }>)
109
108
.then((data) => data.access_token),
110
109
catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`),
111
110
});
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/play.ts
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/play.ts
···
23
23
Effect.catchAll((err) => {
24
24
console.error(err);
25
25
return Effect.succeed({});
26
-
}),
26
+
})
27
27
);
28
28
server.app.rocksky.spotify.play({
29
29
auth: ctx.authVerifier,
···
72
72
.where(eq(tables.spotifyTokens.userId, user.id))
73
73
.execute()
74
74
.then(([spotifyToken]) =>
75
-
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY),
75
+
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY)
76
76
)
77
77
.then((refreshToken) => ({
78
78
user,
···
105
105
client_secret: env.SPOTIFY_CLIENT_SECRET,
106
106
}),
107
107
})
108
-
.then((res) => res.json())
108
+
.then((res) => res.json() as Promise<{ access_token: string }>)
109
109
.then((data) => data.access_token),
110
110
catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`),
111
111
});
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/previous.ts
+3
-3
apps/api/src/xrpc/app/rocksky/spotify/previous.ts
···
23
23
Effect.catchAll((err) => {
24
24
console.error(err);
25
25
return Effect.succeed({});
26
-
}),
26
+
})
27
27
);
28
28
server.app.rocksky.spotify.previous({
29
29
auth: ctx.authVerifier,
···
72
72
.where(eq(tables.spotifyTokens.userId, user.id))
73
73
.execute()
74
74
.then(([spotifyToken]) =>
75
-
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY),
75
+
decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY)
76
76
)
77
77
.then((refreshToken) => ({
78
78
refreshToken,
···
97
97
client_secret: env.SPOTIFY_CLIENT_SECRET,
98
98
}),
99
99
})
100
-
.then((res) => res.json())
100
+
.then((res) => res.json() as Promise<{ access_token: string }>)
101
101
.then((data) => data.access_token),
102
102
catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`),
103
103
});
+1
-1
apps/api/src/xrpc/app/rocksky/spotify/seek.ts
+1
-1
apps/api/src/xrpc/app/rocksky/spotify/seek.ts