OverviewFilesCommitsIssuesDocsReleasesPeers

apds commits / 389328a

try to do a full sync upon receiving new messages. periodically check if we have everything
389328a94d65fa62cd74bc8c5b41e1c32e924fcc
by Everett Bogue <ev@evbogue.com> · 2025-10-19T18:35:54.000Z

Changed files (1) +32 -0

serve.js +32 -0
……@@ -14,6 +14,22 @@ if (!await apds.pubkey()) {
1414
1515const apdsbot = async (ws) => {
1616 ws.onopen = async () => {
17 setTimeout(async () => {
18 const q = await apds.query()
19 for (const m of q) {
20 if (m.text) {
21 const yaml = await apds.parseYaml(m.text)
22 if (yaml.image) {
23 const get = await apds.get(yaml.image)
24 if (!get) {
25 ws.send(yaml.image)
26 }
27 }
28 //console.log(yaml)
29 }
30 }
31 //console.log(q)
32 }, 1000)
1733 console.log('CONNECTED!')
1834 }
1935 ws.onmessage = async (m) => {
……@@ -27,6 +43,22 @@ const apdsbot = async (ws) => {
2743 if (m.data.length != 44) {
2844 await apds.make(m.data)
2945 await apds.add(m.data)
46 const opened = await apds.open(m.data)
47 if (opened) {
48 const content = await apds.get(opened.substring(13))
49 if (!content) {
50 console.log('no content')
51 ws.send(opened.substring(13))
52 }
53 }
54 const yaml = await apds.parseYaml(m.data)
55 if (yaml.previous) {
56 const prev = await apds.get(yaml.previous)
57 if (!prev) {
58 console.log('no previous')
59 ws.send(yaml.previous)
60 }
61 }
3062 }
3163 }
3264 ws.onclose = () => {