Add ActivityPub gateway posting
This commit is contained in:
parent
1c1f645972
commit
757d71af2e
|
@ -147,7 +147,8 @@
|
|||
</div>
|
||||
|
||||
<footer>
|
||||
made by <a href="https://arch.dog" target="_blank">arch</a>
|
||||
made by <a href="https://arch.dog" target="_blank">arch</a> |
|
||||
<a href="https://bird.gmem.ca/@thirdrule" rel="me">activitypub</a>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
|
|
17
index.js
17
index.js
|
@ -10,10 +10,27 @@ async function generateRule(env) {
|
|||
|
||||
export default {
|
||||
async scheduled(event, env, ctx) {
|
||||
const { versionId, versionTag, versionTimestamp } = env.CF_VERSION_METADATA;
|
||||
|
||||
const rule = await generateRule(env);
|
||||
console.log(`generated rule ${JSON.stringify(rule)}`);
|
||||
ctx.waitUntil(env.LOG.put("LATEST", JSON.stringify(rule)));
|
||||
ctx.waitUntil(env.LOG.put(Date.now(), JSON.stringify(rule), { expirationTtl: 31_536_000 }));
|
||||
|
||||
payload = {
|
||||
status: `The secret third rule of the day is\n\n>${rule.response}`,
|
||||
content_type: 'text/markdown',
|
||||
};
|
||||
ctx.waitUntil(await fetch(`https://bird.gmem.ca/api/v1/statuses`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
headers: {
|
||||
"X-Source": "Cloudflare-Workers",
|
||||
"User-Agent": `THIRDRULE ${versionTag}`,
|
||||
"Content-Type": content_type,
|
||||
"Authorization": env.GTS_AUTH
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
||||
async fetch(request, env, ctx) {
|
||||
|
|
Loading…
Reference in a new issue