add an inbox view
This commit is contained in:
@ -238,13 +238,31 @@ app:post("thread_subscribe", "/:slug/subscribe", function(self)
|
||||
subscription:delete()
|
||||
end
|
||||
Subscriptions:create({user_id = user.id, thread_id = thread.id, last_seen = now})
|
||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {after = self.params.first_visible_post})}
|
||||
if self.params.last_visible_post then
|
||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {after = self.params.last_visible_post})}
|
||||
else
|
||||
return {redirect_to = self:url_for("user_inbox", {username = user.username})}
|
||||
end
|
||||
elseif self.params.subscribe == "unsubscribe" then
|
||||
if not subscription then
|
||||
return {status = 404}
|
||||
end
|
||||
subscription:delete()
|
||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {after = self.params.first_visible_post})}
|
||||
if self.params.last_visible_post then
|
||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {after = self.params.last_visible_post})}
|
||||
else
|
||||
return {redirect_to = self:url_for("user_inbox", {username = user.username})}
|
||||
end
|
||||
elseif self.params.subscribe == "read" then
|
||||
if not subscription then
|
||||
return {status = 404}
|
||||
end
|
||||
subscription:update({last_seen = os.time()})
|
||||
if self.params.last_visible_post then
|
||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {after = self.params.last_visible_post})}
|
||||
else
|
||||
return {redirect_to = self:url_for("user_inbox", {username = user.username})}
|
||||
end
|
||||
end
|
||||
|
||||
return {status = 400}
|
||||
|
Reference in New Issue
Block a user