Added testing /api/feed/meet endpoint
This commit is contained in:
parent
0b33e89d81
commit
12f3b4c9cc
|
@ -1,4 +1,5 @@
|
|||
module.exports = {
|
||||
url: require('./api-utils.js').url,
|
||||
accounts: require('./api/accounts.js')
|
||||
accounts: require('./api/accounts.js'),
|
||||
feed: require('./api/feed.js'),
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
const auth = require('../auth.js')
|
||||
|
||||
const FEED_LIMIT = 20
|
||||
|
||||
module.exports = {
|
||||
meet: {
|
||||
// TODO: change algorithm later (to actually get posts instead of accounts)
|
||||
get: [auth.enforceSession, async (req, res) => {
|
||||
const people = await db.table.objects().find({ type: 'Person' })
|
||||
var result = []
|
||||
var addit = -1
|
||||
var count = 0
|
||||
await people.forEach((person) => {
|
||||
if (addit === 1) return
|
||||
if (addit === -1 &&
|
||||
req.query.min_id !== undefined &&
|
||||
req.query.min_id !== String('PUT_A_VALID_ID_HERE'))
|
||||
return
|
||||
|
||||
addit = 0
|
||||
count++
|
||||
if (count > FEED_LIMIT)
|
||||
addit = 1
|
||||
|
||||
// TODO: o
|
||||
if (addit === 0) {
|
||||
const acct = person.preferredUsername[0]+'@'+
|
||||
(new URL(person.id).hostname)
|
||||
result.push({
|
||||
_id: 'PUT_A_VALID_ID_HERE',
|
||||
text: 'this is a test',
|
||||
date: new Date().getTime() - 2000,
|
||||
account: {
|
||||
_id: person._id,
|
||||
url: person.id,
|
||||
acct: acct,
|
||||
name: person.name[0],
|
||||
username: person.preferredUsername[0],
|
||||
avatar: person.icon,
|
||||
summary: person.summary[0],
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
res.json(result)
|
||||
}],
|
||||
},
|
||||
}
|
|
@ -68,6 +68,7 @@ app.on('apex-inbox', activity.federation.inbox)
|
|||
// API defines
|
||||
app.route(api.url('/accounts/register')).post(api.accounts.register.post)
|
||||
app.route(api.url('/accounts/login')).post(api.accounts.login.post)
|
||||
app.route(api.url('/feed/meet')).get(api.feed.meet.get)
|
||||
|
||||
|
||||
// initialize
|
||||
|
|
Loading…
Reference in New Issue