# HG changeset patch # User Matthew Wild # Date 1324297743 0 # Node ID 46e1983486e91ad0251238ddf52748f63c57efad # Parent 5e8843a869a32387cb0ad254fc4b2728c67d8b04 mod_pastebin: Support for persistent pastes (set pastebin_expire_after = 0) diff -r 5e8843a869a3 -r 46e1983486e9 mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Mon Dec 19 11:38:57 2011 +0000 +++ b/mod_pastebin/mod_pastebin.lua Mon Dec 19 12:29:03 2011 +0000 @@ -44,6 +44,24 @@ local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; +if expire_after == 0 then + local dm = require "util.datamanager"; + setmetatable(pastes, { + __index = function (pastes, id) + if type(id) == "string" then + return dm.load(id, module.host, "pastebin"); + end + end; + __newindex = function (pastes, id, data) + if type(id) == "string" then + dm.store(id, module.host, "pastebin", data); + end + end; + }); +else + setmetatable(pastes, nil); +end + function pastebin_text(text) local uuid = uuid_new(); pastes[uuid] = { body = text, time = os_time(), headers = default_headers };