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
import type { BlobRef } from "@atproto/lexicon";
2
import { isValidHandle } from "@atproto/syntax";
3
import { ctx } from "context";
4
-
import { and, desc, eq, sql } from "drizzle-orm";
5
import { Hono } from "hono";
6
import jwt from "jsonwebtoken";
7
import * as Profile from "lexicon/types/app/bsky/actor/profile";
···
145
await ctx.db
146
.insert(users)
147
.values({
148
-
id: sql`xata_id()`,
149
did,
150
handle,
151
displayName: profile.displayName,
···
1
import type { BlobRef } from "@atproto/lexicon";
2
import { isValidHandle } from "@atproto/syntax";
3
import { ctx } from "context";
4
+
import { and, desc, eq } from "drizzle-orm";
5
import { Hono } from "hono";
6
import jwt from "jsonwebtoken";
7
import * as Profile from "lexicon/types/app/bsky/actor/profile";
···
145
await ctx.db
146
.insert(users)
147
.values({
0
148
did,
149
handle,
150
displayName: profile.displayName,
+9
-10
apps/api/src/xrpc/app/rocksky/actor/getProfile.ts
···
33
Effect.catchAll((err) => {
34
console.error(err);
35
return Effect.succeed({});
36
-
}),
37
);
38
server.app.rocksky.actor.getProfile({
39
auth: ctx.authVerifier,
···
194
.from(tables.spotifyAccounts)
195
.leftJoin(
196
tables.users,
197
-
eq(tables.spotifyAccounts.userId, tables.users.id),
198
)
199
.where(eq(tables.users.did, did))
200
.execute()
···
204
.from(tables.spotifyTokens)
205
.leftJoin(
206
tables.users,
207
-
eq(tables.spotifyTokens.userId, tables.users.id),
208
)
209
.where(eq(tables.users.did, did))
210
.execute()
···
214
.from(tables.googleDriveAccounts)
215
.leftJoin(
216
tables.users,
217
-
eq(tables.googleDriveAccounts.userId, tables.users.id),
218
)
219
.where(eq(tables.users.did, did))
220
.execute()
···
224
.from(tables.dropboxAccounts)
225
.leftJoin(
226
tables.users,
227
-
eq(tables.dropboxAccounts.userId, tables.users.id),
228
)
229
.where(eq(tables.users.did, did))
230
.execute()
···
256
await profile.ctx.db
257
.insert(tables.users)
258
.values({
259
-
id: "",
260
did: profile.did,
261
handle,
262
avatar: `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg`,
···
281
xata_createdat: profile.user.createdAt.toISOString(),
282
xata_updatedat: profile.user.updatedAt.toISOString(),
283
xata_version: 1,
284
-
}),
285
-
),
286
);
287
} else {
288
// Update existing user in background if handle or avatar or displayName changed
···
315
xata_createdat: profile.user.createdAt.toISOString(),
316
xata_updatedat: new Date().toISOString(),
317
xata_version: (profile.user.xataVersion || 1) + 1,
318
-
}),
319
-
),
320
);
321
}
322
}
···
33
Effect.catchAll((err) => {
34
console.error(err);
35
return Effect.succeed({});
36
+
})
37
);
38
server.app.rocksky.actor.getProfile({
39
auth: ctx.authVerifier,
···
194
.from(tables.spotifyAccounts)
195
.leftJoin(
196
tables.users,
197
+
eq(tables.spotifyAccounts.userId, tables.users.id)
198
)
199
.where(eq(tables.users.did, did))
200
.execute()
···
204
.from(tables.spotifyTokens)
205
.leftJoin(
206
tables.users,
207
+
eq(tables.spotifyTokens.userId, tables.users.id)
208
)
209
.where(eq(tables.users.did, did))
210
.execute()
···
214
.from(tables.googleDriveAccounts)
215
.leftJoin(
216
tables.users,
217
+
eq(tables.googleDriveAccounts.userId, tables.users.id)
218
)
219
.where(eq(tables.users.did, did))
220
.execute()
···
224
.from(tables.dropboxAccounts)
225
.leftJoin(
226
tables.users,
227
+
eq(tables.dropboxAccounts.userId, tables.users.id)
228
)
229
.where(eq(tables.users.did, did))
230
.execute()
···
256
await profile.ctx.db
257
.insert(tables.users)
258
.values({
0
259
did: profile.did,
260
handle,
261
avatar: `https://cdn.bsky.app/img/avatar/plain/${profile.did}/${_.get(profile, "profileRecord.value.avatar.ref", "").toString()}@jpeg`,
···
280
xata_createdat: profile.user.createdAt.toISOString(),
281
xata_updatedat: profile.user.updatedAt.toISOString(),
282
xata_version: 1,
283
+
})
284
+
)
285
);
286
} else {
287
// Update existing user in background if handle or avatar or displayName changed
···
314
xata_createdat: profile.user.createdAt.toISOString(),
315
xata_updatedat: new Date().toISOString(),
316
xata_version: (profile.user.xataVersion || 1) + 1,
317
+
})
318
+
)
319
);
320
}
321
}