add notification for new post in thread
This commit is contained in:
11
util.lua
11
util.lua
@ -9,6 +9,7 @@ local Avatars = require("models").Avatars
|
||||
local Users = require("models").Users
|
||||
local Posts = require("models").Posts
|
||||
local PostHistory = require("models").PostHistory
|
||||
local Threads = require("models").Threads
|
||||
|
||||
local babycode = require("lib.babycode")
|
||||
|
||||
@ -103,6 +104,16 @@ function util.split_sentences(sentences, max_sentences)
|
||||
return util.s_split(sentences, ".", max_sentences or 2, true, false)
|
||||
end
|
||||
|
||||
---@return string
|
||||
function util.get_post_url(req, post_id)
|
||||
local post = Posts:find({id = post_id})
|
||||
if not post then return "" end
|
||||
local thread = Threads:find({id = post.thread_id})
|
||||
if not thread then return "" end
|
||||
|
||||
return req:url_for("thread", {slug = thread.slug}, {after = post_id}) .. "#post-" .. post_id
|
||||
end
|
||||
|
||||
function util.infobox_message(msg)
|
||||
local sentences = util.split_sentences(msg)
|
||||
if #sentences == 1 then
|
||||
|
Reference in New Issue
Block a user