425ca29 / social.mjs
diff --git a/social.mjs b/social.mjs
index a8880e6..4429fdf 100644
--- a/social.mjs
+++ b/social.mjs
@@ -20,3 +20,12 @@ export async function verifyPost(record) {
validatePost(body)
return { id: record.id, author, timestamp, text: body.text, replyTo: body.replyTo }
}
+
+export async function verifyPushAnnouncement(record, author, repoId) {
+ const { body, timestamp } = await verifyRecordDetails(record, author)
+ requireThat(body?.anbot === 1 && body.type === 'git-push' && body.repoId === repoId &&
+ typeof body.ref === 'string' && body.ref.startsWith('refs/heads/') &&
+ typeof body.commit === 'string' && /^[0-9a-f]{40}$/.test(body.commit),
+ 'Invalid push announcement')
+ return { id: record.id, author, timestamp, ref: body.ref, commit: body.commit }
+}
Git ยท Social feed