Mercurial > prosody-modules
comparison mod_webpresence/mod_webpresence.lua @ 847:1c9a3454eb43
mod_webpresence: Don't calculate the same hash four times.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sat, 13 Oct 2012 03:31:26 +0500 |
| parents | 2d83708ea901 |
| children | 432dc4056114 |
comparison
equal
deleted
inserted
replaced
| 846:5ddc43ce8993 | 847:1c9a3454eb43 |
|---|---|
| 54 if type == "" then type = "image" end; | 54 if type == "" then type = "image" end; |
| 55 if type == "image" then | 55 if type == "image" then |
| 56 statuses[status].image = { status_code = 200, headers = { content_type = "image/png" }, | 56 statuses[status].image = { status_code = 200, headers = { content_type = "image/png" }, |
| 57 body = require_resource("status_"..status..".png") }; | 57 body = require_resource("status_"..status..".png") }; |
| 58 elseif type == "html" then | 58 elseif type == "html" then |
| 59 local jid_hash = sha1(jid, true); | |
| 59 statuses[status].html = { status_code = 200, headers = { content_type = "text/html" }, | 60 statuses[status].html = { status_code = 200, headers = { content_type = "text/html" }, |
| 60 body = [[<div id="]]..sha1(jid,true)..[[_status" class="xmpp_status">]].. | 61 body = [[<div id="]]..jid_hash..[[_status" class="xmpp_status">]].. |
| 61 [[<img id="]]..sha1(jid,true)..[[_img" class="xmpp_status_image" ]].. | 62 [[<img id="]]..jid_hash..[[_img" class="xmpp_status_image" ]].. |
| 62 [[src="data:image/png;base64,]].. | 63 [[src="data:image/png;base64,]].. |
| 63 b64(require_resource("status_"..status..".png"))..[[">]].. | 64 b64(require_resource("status_"..status..".png"))..[[">]].. |
| 64 [[<span id="]]..sha1(jid,true)..[[_name" ]].. | 65 [[<span id="]]..jid_hash..[[_name" ]].. |
| 65 [[class="xmpp_status_name">]]..status..[[</span>]].. | 66 [[class="xmpp_status_name">]]..status..[[</span>]].. |
| 66 (message and [[<span id="]]..sha1(jid,true)..[[_message" ]].. | 67 (message and [[<span id="]]..jid_hash..[[_message" ]].. |
| 67 [[class="xmpp_status_message">]]..message..[[</span>]] or "").. | 68 [[class="xmpp_status_message">]]..message..[[</span>]] or "").. |
| 68 [[</div>]] }; | 69 [[</div>]] }; |
| 69 elseif type == "text" then | 70 elseif type == "text" then |
| 70 statuses[status].text = { status_code = 200, headers = { content_type = "text/plain" }, | 71 statuses[status].text = { status_code = 200, headers = { content_type = "text/plain" }, |
| 71 body = status }; | 72 body = status }; |
