tangled
alpha
login
or
join now
rocksky.app
/
rocksky
96
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
96
fork
atom
overview
issues
7
pulls
pipelines
Merge branch 'main' into feat/feed-generator
tsiry-sandratraina.com
3 months ago
f8ae9616
d3573087
+10
-12
2 changed files
expand all
collapse all
unified
split
apps
api
src
bsky
app.ts
xrpc
app
rocksky
actor
getProfile.ts
+1
-2
apps/api/src/bsky/app.ts
···
1
1
import type { BlobRef } from "@atproto/lexicon";
2
2
import { isValidHandle } from "@atproto/syntax";
3
3
import { ctx } from "context";
4
4
-
import { and, desc, eq, sql } from "drizzle-orm";
4
4
+
import { and, desc, eq } from "drizzle-orm";
5
5
import { Hono } from "hono";
6
6
import jwt from "jsonwebtoken";
7
7
import * as Profile from "lexicon/types/app/bsky/actor/profile";
···
145
145
await ctx.db
146
146
.insert(users)
147
147
.values({
148
148
-
id: sql`xata_id()`,
149
148
did,
150
149
handle,
151
150
displayName: profile.displayName,
+9
-10
apps/api/src/xrpc/app/rocksky/actor/getProfile.ts
···
33
33
Effect.catchAll((err) => {
34
34
console.error(err);
35
35
return Effect.succeed({});
36
36
-
}),
36
36
+
})
37
37
);
38
38
server.app.rocksky.actor.getProfile({
39
39
auth: ctx.authVerifier,
···
194
194
.from(tables.spotifyAccounts)
195
195
.leftJoin(
196
196
tables.users,
197
197
-
eq(tables.spotifyAccounts.userId, tables.users.id),
197
197
+
eq(tables.spotifyAccounts.userId, tables.users.id)
198
198
)
199
199
.where(eq(tables.users.did, did))
200
200
.execute()
···
204
204
.from(tables.spotifyTokens)
205
205
.leftJoin(
206
206
tables.users,
207
207
-
eq(tables.spotifyTokens.userId, tables.users.id),
207
207
+
eq(tables.spotifyTokens.userId, tables.users.id)
208
208
)
209
209
.where(eq(tables.users.did, did))
210
210
.execute()
···
214
214
.from(tables.googleDriveAccounts)
215
215
.leftJoin(
216
216
tables.users,
217
217
-
eq(tables.googleDriveAccounts.userId, tables.users.id),
217
217
+
eq(tables.googleDriveAccounts.userId, tables.users.id)
218
218
)
219
219
.where(eq(tables.users.did, did))
220
220
.execute()
···
224
224
.from(tables.dropboxAccounts)
225
225
.leftJoin(
226
226
tables.users,
227
227
-
eq(tables.dropboxAccounts.userId, tables.users.id),
227
227
+
eq(tables.dropboxAccounts.userId, tables.users.id)
228
228
)
229
229
.where(eq(tables.users.did, did))
230
230
.execute()
···
256
256
await profile.ctx.db
257
257
.insert(tables.users)
258
258
.values({
259
259
-
id: "",
260
259
did: profile.did,
261
260
handle,
262
261
avatar: `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg`,
···
281
280
xata_createdat: profile.user.createdAt.toISOString(),
282
281
xata_updatedat: profile.user.updatedAt.toISOString(),
283
282
xata_version: 1,
284
284
-
}),
285
285
-
),
283
283
+
})
284
284
+
)
286
285
);
287
286
} else {
288
287
// Update existing user in background if handle or avatar or displayName changed
···
315
314
xata_createdat: profile.user.createdAt.toISOString(),
316
315
xata_updatedat: new Date().toISOString(),
317
316
xata_version: (profile.user.xataVersion || 1) + 1,
318
318
-
}),
319
319
-
),
317
317
+
})
318
318
+
)
320
319
);
321
320
}
322
321
}