···
// Update the session cookie
session.did = oauth.session.did
-
// Redirect to the homepage
-
return res.redirect('/')
ctx.logger.error({ err }, 'oauth callback failed')
return res.redirect('/?error')
-
handler((req: Request, res: Response) => {
res.type('html').send(page(login({})))
···
res.type('html').send(page(login({ error: 'invalid input' })))
// Initiate the OAuth flow
···
handler(async (req: Request, res: Response) => {
-
const error = ifString(req.query.error)
// If the user is signed in, get an agent which communicates with their server
const agent = await getSessionAgent(req, res, ctx)
···
// Serve the logged-out view
-
res.type('html').send(page(home({ error, statuses, didHandleMap })))
···
// Serve the logged-in view
-
.send(page(home({ error, statuses, didHandleMap, profile, myStatus })))
···
// If the user is signed in, get an agent which communicates with their server
const agent = await getSessionAgent(req, res, ctx)
-
res.redirect(`/login}`)
-
const status = req.body?.status
-
if (typeof status !== 'string' || !STATUS_OPTIONS.includes(status)) {
-
throw new Error('Invalid status')
-
// Construct & validate their status record
-
const rkey = TID.nextStr()
-
$type: 'xyz.statusphere.status',
-
createdAt: new Date().toISOString(),
-
if (!Status.validateRecord(record).success) {
-
res.status(400).type('html').send('<h1>Error: Invalid status</h1>')
-
// Write the status record to the user's repository
-
const res = await agent.com.atproto.repo.putRecord({
-
collection: 'xyz.statusphere.status',
-
ctx.logger.error({ err }, 'failed to write record')
-
.send('<h1>Error: Failed to write record</h1>')
-
// Optimistically update our SQLite
-
// This isn't strictly necessary because the write event will be
-
// handled in #/firehose/ingestor.ts, but it ensures that future reads
-
// will be up-to-date after this method finishes.
-
authorDid: agent.assertDid,
-
createdAt: record.createdAt,
-
indexedAt: new Date().toISOString(),
-
'failed to update computed view; ignoring as it should be caught by the firehose',
-
const message = err instanceof Error ? err.message : 'Unknown error'
-
res.redirect(`/?error=${encodeURIComponent(message)}`)
···
// Update the session cookie
session.did = oauth.session.did
ctx.logger.error({ err }, 'oauth callback failed')
return res.redirect('/?error')
+
return res.redirect('/')
+
handler(async (req: Request, res: Response) => {
res.type('html').send(page(login({})))
···
res.type('html').send(page(login({ error: 'invalid input' })))
+
// @NOTE input can be a handle, a DID or a service URL (PDS).
// Initiate the OAuth flow
···
handler(async (req: Request, res: Response) => {
// If the user is signed in, get an agent which communicates with their server
const agent = await getSessionAgent(req, res, ctx)
···
// Serve the logged-out view
+
res.type('html').send(page(home({ statuses, didHandleMap })))
···
// Serve the logged-in view
···
// If the user is signed in, get an agent which communicates with their server
const agent = await getSessionAgent(req, res, ctx)
+
const status = ifString(req.body?.status)
+
if (!status || !STATUS_OPTIONS.includes(status)) {
+
throw new Error('Invalid status')
+
// Construct & validate their status record
+
const rkey = TID.nextStr()
+
$type: 'xyz.statusphere.status',
+
createdAt: new Date().toISOString(),
+
if (!Status.validateRecord(record).success) {
+
res.status(400).type('html').send('<h1>Error: Invalid status</h1>')
+
// Write the status record to the user's repository
+
const res = await agent.com.atproto.repo.putRecord({
+
collection: 'xyz.statusphere.status',
+
ctx.logger.warn({ err }, 'failed to write record')
+
.send('<h1>Error: Failed to write record</h1>')
+
// Optimistically update our SQLite
+
// This isn't strictly necessary because the write event will be
+
// handled in #/firehose/ingestor.ts, but it ensures that future reads
+
// will be up-to-date after this method finishes.
+
authorDid: agent.assertDid,
+
createdAt: record.createdAt,
+
indexedAt: new Date().toISOString(),
+
'failed to update computed view; ignoring as it should be caught by the firehose',