tangled
alpha
login
or
join now
ducky.ws
/
playground
1
fork
atom
Monorepo for @ducky.ws's experiments and scripts
ducky.ws
1
fork
atom
overview
issues
pulls
pipelines
bsky-avatar-clock: add ability to override avatar CID
ducky.ws
1 month ago
b5bb4e70
be546f82
+21
-14
1 changed file
expand all
collapse all
unified
split
code
deno
bsky-avatar-clock.ts
+21
-14
code/deno/bsky-avatar-clock.ts
···
38
38
let ATPROTO_PASSWORD = getEnvvar("atproto_password");
39
39
let ATPROTO_PDS = getEnvvar("atproto_pds") || "https://bsky.social";
40
40
let CRON = getEnvvar("bac_cron") || "*/20 * * * *";
41
41
+
let FORCE_BLOB_CID = getEnvvar("force_blob_cid");
41
42
42
43
// --- Types / Interfaces ---
43
44
···
97
98
const profile = await getBskyProfile(did);
98
99
let blobCid = null;
99
100
100
100
-
if(profile.data.value["x-clock"] === undefined) {
101
101
-
if(profile.data.value.avatar !== undefined)
102
102
-
blobCid = (profile.data.value.avatar as Blob).ref.$link;
101
101
+
if(FORCE_BLOB_CID === null) {
102
102
+
if(profile.data.value["x-clock"] === undefined) {
103
103
+
if(profile.data.value.avatar !== undefined)
104
104
+
blobCid = (profile.data.value.avatar as Blob).ref.$link;
105
105
+
} else {
106
106
+
if(profile.data.value["x-clock"].originalAvatar !== undefined)
107
107
+
blobCid = (profile.data.value["x-clock"].originalAvatar as Blob).ref.$link;
108
108
+
}
103
109
} else {
104
104
-
if(profile.data.value["x-clock"].originalAvatar !== undefined)
105
105
-
blobCid = (profile.data.value["x-clock"].originalAvatar as Blob).ref.$link;
110
110
+
blobCid = FORCE_BLOB_CID;
106
111
}
107
112
108
113
if(blobCid !== null)
···
258
263
"$type": "app.bsky.actor.profile"
259
264
};
260
265
261
261
-
if(currentProfile.data.value["x-clock"] === undefined) {
262
262
-
const newClock: Clock = {
263
263
-
originalAvatar: currentProfile.data.value.avatar as Blob,
264
264
-
status: status
265
265
-
}
266
266
+
if(FORCE_BLOB_CID === null) {
267
267
+
if(currentProfile.data.value["x-clock"] === undefined) {
268
268
+
const newClock: Clock = {
269
269
+
originalAvatar: currentProfile.data.value.avatar as Blob,
270
270
+
status: status
271
271
+
}
266
272
267
267
-
newProfileRecord["x-clock"] = newClock;
268
268
-
} else {
269
269
-
newProfileRecord["x-clock"] = currentProfile.data.value["x-clock"];
270
270
-
newProfileRecord["x-clock"].status = status;
273
273
+
newProfileRecord["x-clock"] = newClock;
274
274
+
} else {
275
275
+
newProfileRecord["x-clock"] = currentProfile.data.value["x-clock"];
276
276
+
newProfileRecord["x-clock"].status = status;
277
277
+
}
271
278
}
272
279
273
280
const newProfile = await ATPROTO_CLIENT.call(ComAtprotoRepoApplyWrites, {