add an inbox view

This commit is contained in:
2025-06-02 23:05:28 +03:00
parent bd1ba6c087
commit 22526c953e
11 changed files with 178 additions and 6 deletions

View File

@ -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}