on post create, update subscription if subscribed
This commit is contained in:
parent
303e032673
commit
51eadc20ec
@ -145,13 +145,12 @@ app:post("thread", "/:slug", function(self)
|
|||||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {page = last_page}) .. "#latest-post"}
|
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {page = last_page}) .. "#latest-post"}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.params.subscribe == "on" then
|
local subscription = Subscriptions:find({user_id = user.id, thread_id = thread.id})
|
||||||
local subscription = Subscriptions:find({user_id = user.id, thread_id = thread.id})
|
if subscription then
|
||||||
if subscription then
|
subscription:update({last_seen = os.time})
|
||||||
subscription:update({last_seen = os.time})
|
end
|
||||||
else
|
if self.params.subscribe == "on" and not subscription then
|
||||||
Subscriptions:create({user_id = user.id, thread_id = thread.id, last_seen = os.time()})
|
Subscriptions:create({user_id = user.id, thread_id = thread.id, last_seen = os.time()})
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {page = last_page}) .. "#latest-post"}
|
return {redirect_to = self:url_for("thread", {slug = thread.slug}, {page = last_page}) .. "#latest-post"}
|
||||||
|
Loading…
Reference in New Issue
Block a user