Add support for viewing mentions
This commit is contained in:
parent
833275013e
commit
136df89836
File diff suppressed because it is too large
Load Diff
|
@ -22,6 +22,7 @@ module.exports = (config) => {
|
|||
const like = require('./pages/like')
|
||||
const status = require('./pages/status')
|
||||
const highlight = require('./pages/highlight')
|
||||
const mentions = require('./pages/mentions')
|
||||
|
||||
const assets = new Koa()
|
||||
assets.use(koaStatic(path.join(__dirname, 'assets')))
|
||||
|
@ -66,6 +67,9 @@ module.exports = (config) => {
|
|||
.get('/status/', async (ctx) => {
|
||||
ctx.body = await status()
|
||||
})
|
||||
.get('/mentions/', async (ctx) => {
|
||||
ctx.body = await mentions()
|
||||
})
|
||||
.get('/thread/:message', async (ctx) => {
|
||||
const { message } = ctx.params
|
||||
ctx.body = await thread(message)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
const post = require('./models/post')
|
||||
const listView = require('./views/list')
|
||||
|
||||
module.exports = async function hashtag (channel) {
|
||||
const messages = await post.mentionsMe()
|
||||
|
||||
return listView({ messages })
|
||||
}
|
|
@ -129,6 +129,41 @@ module.exports = {
|
|||
|
||||
return messages
|
||||
},
|
||||
mentionsMe: async (customOptions = {}) => {
|
||||
const ssb = await cooler.connect()
|
||||
|
||||
const whoami = await cooler.get(ssb.whoami)
|
||||
const myFeedId = whoami.id
|
||||
|
||||
const query = [{
|
||||
$filter: {
|
||||
dest: myFeedId
|
||||
}
|
||||
}]
|
||||
|
||||
const options = configure({ query, index: 'DTA' }, customOptions)
|
||||
|
||||
const source = await cooler.read(
|
||||
ssb.backlinks.read, options
|
||||
)
|
||||
|
||||
const messages = await new Promise((resolve, reject) => {
|
||||
pull(
|
||||
source,
|
||||
pull.filter(msg =>
|
||||
typeof msg.value.content !== 'string' &&
|
||||
msg.value.content.type === 'post'
|
||||
),
|
||||
pull.take(32),
|
||||
pull.collect((err, messages) => {
|
||||
if (err) return reject(err)
|
||||
resolve(transform(ssb, messages, myFeedId))
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
return messages
|
||||
},
|
||||
fromHashtag: async (hashtag, customOptions = {}) => {
|
||||
const ssb = await cooler.connect()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = (...elements) => {
|
|||
body(
|
||||
nav(
|
||||
a({ href: '/' }, 'home'),
|
||||
a({ href: '/mentions' }, 'mentions'),
|
||||
a({ href: '/profile' }, 'profile'),
|
||||
a({ href: '/status' }, 'status'),
|
||||
a({ href: 'https://github.com/fraction/oasis' }, 'source'),
|
||||
|
|
Loading…
Reference in New Issue