Public
Edited
Nov 30, 2024
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topTrending = deploy(
"tweetTopTrending",
async (req, res, context) => {
const hasSent = (await db.child(contentHash).once("value")).val() !== null;
if (hasSent) return res.send("Already sent");
else {
try {
const response = await postWithImage(
"trendingnotebooks.bsky.social",
context.secrets["BLUESKY_TRENDING_APP_PASSWORD"],
imgBlob,
text
);
await db.child(contentHash).set(true);
return res.send(JSON.stringify(response));
} catch (err) {
return res.status(400).send(err.message);
}
}
},
{
modifiers: ["orchestrator"],
secrets: ["endpointservices_BLUESKY_TRENDING_APP_PASSWORD"]
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sendTweet = createTrigger({
name: "sendTweet",
authorized_public_keys: ["cg24TseUZnvEiO3XtXCFD08E9bX83Sv4rBHe2cjvpmU="],
// Serverside check, ensure only the current trending tweet is used
checkPayload: (payload) => payload.text === text && payload.img.startsWith("https://static.observableusercontent.com/thumbnail/"),
sample: {
text: text,
img: imgURL
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
postWithImage("trendingnotebooks.bsky.social", password, imgBlob, text)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
contentHash = hash(text)
Insert cell
contentHash.length
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more