+10
-7
index.ts
+10
-7
index.ts
···
43
43
}
44
44
45
45
const headers = {
46
-
'User-Agent': 'unfollower-script/did:plc:qttsv4e7pu2jl3ilanfgc3zn'
46
+
'User-Agent': 'swab/https://tangled.org/dane.is.extraordinarily.cool/swab'
47
47
}
48
48
49
49
const MONTHS_IN_DAYS = 183 // 6 months, seems reasonable
···
61
61
try {
62
62
const response = await fetch(`https://slingshot.microcosm.blue/xrpc/com.bad-example.identity.resolveMiniDoc?identifier=${indentifier}`, {headers})
63
63
if (!response.ok) {
64
-
throw new Error(`Failed to fetch minidoc for ${indentifier}. Status - ${response.status}`)
64
+
// throw new Error(`Failed to fetch minidoc for ${indentifier}. Status - ${response.status}`)
65
+
console.error(`Failed to fetch minidoc for ${indentifier}. Status - ${response.status}`)
65
66
}
66
67
const data = await response.json() as MiniDoc
67
68
return data
···
77
78
try {
78
79
const response = await fetch(`${doc.pds}/xrpc/com.atproto.repo.listRecords?repo=${doc.did}&collection=app.bsky.feed.post&limit=1`, {headers})
79
80
if (!response.ok) {
80
-
throw new Error(`There was an error fetching posts for ${doc.handle}. Status - ${response.status}`)
81
+
// throw new Error(`There was an error fetching posts for ${doc.handle}. Status - ${response.status}`)
82
+
console.error(`There was an error fetching posts for ${doc.handle}. Status - ${response.status}`)
81
83
}
82
84
const data = await response.json() as {records: Post[]}
83
85
return data;
···
94
96
try {
95
97
const response = await fetch(`https://public.api.bsky.app/xrpc/app.bsky.graph.getFollows?actor=${did}&cursor=${cursor}&limit=100`)
96
98
if (!response.ok) {
97
-
throw new Error(`There was a problem getting follows for ${did}. Status - ${response.status}`)
99
+
// throw new Error(`There was a problem getting follows for ${did}. Status - ${response.status}`)
100
+
console.error(`There was a problem getting follows for ${did}. Status - ${response.status}`)
98
101
}
99
102
100
103
const data = await response.json() as {
···
123
126
for (const [index, follower] of follows.entries()) {
124
127
const doc = await resolveIdentity(follower.did)
125
128
const post = await getRecentPost(doc)
126
-
const recentPostCreationDate = post?.records?.[0]!.value?.createdAt
127
129
128
130
129
131
// it's possible that someone has never made a post i guess, we should add them to the list
···
131
133
// neg 1 can represent never made post
132
134
unfollowMap.set(follower.handle, -1)
133
135
}
134
-
if (post?.records[0] && post?.records[0]?.value && !isNaN(Date.parse(recentPostCreationDate))) {
136
+
if (post?.records[0] && post?.records[0]?.value) {
137
+
const recentPostCreationDate = post?.records?.[0].value?.createdAt
135
138
// invalid date for some reason idk
136
139
const daysSinceLastPost = getDateDifferenceInDays(new Date(recentPostCreationDate), new Date())
137
140
if (daysSinceLastPost >= MONTHS_IN_DAYS) {
···
142
145
console.info(`Auditing user [${index + 1} / ${follows.length}]`)
143
146
}
144
147
145
-
await new Promise((resolve) => setTimeout(resolve, 1000))
148
+
// await new Promise((resolve) => setTimeout(resolve, 1000))
146
149
}
147
150
cursor = followsCursor
148
151
} while (cursor)