show channel when rendering post, show all followed channels in user-feed
This commit is contained in:
@@ -143,26 +143,40 @@ exports.init = function (sbot, config) {
|
|||||||
console.log("serving user feed: " + feedId)
|
console.log("serving user feed: " + feedId)
|
||||||
|
|
||||||
var following = []
|
var following = []
|
||||||
|
var channelSubscriptions = []
|
||||||
|
|
||||||
pull(
|
pull(
|
||||||
sbot.createUserStream({ id: feedId }),
|
sbot.createUserStream({ id: feedId }),
|
||||||
pull.filter((msg) => {
|
pull.filter((msg) => {
|
||||||
return !msg.value || msg.value.content.type == 'contact'
|
return !msg.value ||
|
||||||
|
msg.value.content.type == 'contact' ||
|
||||||
|
(msg.value.content.type == 'channel' &&
|
||||||
|
typeof msg.value.content.subscribed != 'undefined')
|
||||||
}),
|
}),
|
||||||
pull.collect(function (err, msgs) {
|
pull.collect(function (err, msgs) {
|
||||||
msgs.forEach((msg) => {
|
msgs.forEach((msg) => {
|
||||||
if (msg.value.content.following)
|
if (msg.value.content.type == 'contact')
|
||||||
following[msg.value.content.contact] = 1
|
{
|
||||||
else
|
if (msg.value.content.following)
|
||||||
delete following[msg.value.content.contact]
|
following[msg.value.content.contact] = 1
|
||||||
|
else
|
||||||
|
delete following[msg.value.content.contact]
|
||||||
|
}
|
||||||
|
else // channel subscription
|
||||||
|
{
|
||||||
|
if (msg.value.content.subscribed)
|
||||||
|
channelSubscriptions[msg.value.content.channel] = 1
|
||||||
|
else
|
||||||
|
delete following[msg.value.content.channel]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
serveFeeds(req, res, following, feedId)
|
serveFeeds(req, res, following, channelSubscriptions, feedId)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function serveFeeds(req, res, following, feedId) {
|
function serveFeeds(req, res, following, channelSubscriptions, feedId) {
|
||||||
var opts = defaultOpts
|
var opts = defaultOpts
|
||||||
|
|
||||||
opts.marked = {
|
opts.marked = {
|
||||||
@@ -181,7 +195,9 @@ exports.init = function (sbot, config) {
|
|||||||
pull(
|
pull(
|
||||||
sbot.createLogStream({ reverse: true, limit: 1000 }),
|
sbot.createLogStream({ reverse: true, limit: 1000 }),
|
||||||
pull.filter((msg) => {
|
pull.filter((msg) => {
|
||||||
return !msg.value || msg.value.author in following
|
return !msg.value ||
|
||||||
|
(msg.value.author in following ||
|
||||||
|
msg.value.content.channel in channelSubscriptions)
|
||||||
}),
|
}),
|
||||||
pull.filter((msg) => { // channel subscription
|
pull.filter((msg) => { // channel subscription
|
||||||
return !msg.value.content.subscribed
|
return !msg.value.content.subscribed
|
||||||
@@ -229,6 +245,9 @@ exports.init = function (sbot, config) {
|
|||||||
pull.filter((msg) => {
|
pull.filter((msg) => {
|
||||||
return !msg.value || msg.value.content.channel == channelId
|
return !msg.value || msg.value.content.channel == channelId
|
||||||
}),
|
}),
|
||||||
|
pull.filter((msg) => { // channel subscription
|
||||||
|
return !msg.value.content.subscribed
|
||||||
|
}),
|
||||||
pull.collect(function (err, logs) {
|
pull.collect(function (err, logs) {
|
||||||
if (err) return respond(res, 500, err.stack || err)
|
if (err) return respond(res, 500, err.stack || err)
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
@@ -561,9 +580,10 @@ function formatDate(date) {
|
|||||||
|
|
||||||
function render(opts, c)
|
function render(opts, c)
|
||||||
{
|
{
|
||||||
if (c.type === 'post')
|
if (c.type === 'post') {
|
||||||
return renderPost(opts, c)
|
var channel = c.channel ? ' in #' + c.channel : ''
|
||||||
else if (c.type == 'vote' && c.vote.expression == 'Dig') {
|
return channel + renderPost(opts, c)
|
||||||
|
} else if (c.type == 'vote' && c.vote.expression == 'Dig') {
|
||||||
var channel = c.channel ? ' in #' + c.channel : ''
|
var channel = c.channel ? ' in #' + c.channel : ''
|
||||||
var linkedText = 'this'
|
var linkedText = 'this'
|
||||||
if (typeof c.vote.linkedText != 'undefined')
|
if (typeof c.vote.linkedText != 'undefined')
|
||||||
|
|||||||
Reference in New Issue
Block a user