Mercurial > prosody-hg
comparison util/prosodyctl/check.lua @ 13768:4365f0f03c33 13.0
prosodyctl check features: Report size limit for HTTP upload
This also adds a generic "meta" mechanism where checks can return annotations.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 13 Mar 2025 11:33:08 +0000 |
| parents | 56fad06904b1 |
| children | b6d0f1d79b60 |
comparison
equal
deleted
inserted
replaced
| 13767:56fad06904b1 | 13768:4365f0f03c33 |
|---|---|
| 9 local socket_url = require "socket.url"; | 9 local socket_url = require "socket.url"; |
| 10 local jid_split = require "prosody.util.jid".prepped_split; | 10 local jid_split = require "prosody.util.jid".prepped_split; |
| 11 local modulemanager = require "prosody.core.modulemanager"; | 11 local modulemanager = require "prosody.core.modulemanager"; |
| 12 local async = require "prosody.util.async"; | 12 local async = require "prosody.util.async"; |
| 13 local httputil = require "prosody.util.http"; | 13 local httputil = require "prosody.util.http"; |
| 14 local human_units = require "prosody.util.human.units"; | |
| 14 | 15 |
| 15 local function api(host) | 16 local function api(host) |
| 16 return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi }) | 17 return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi }) |
| 17 end | 18 end |
| 18 | 19 |
| 1554 end | 1555 end |
| 1555 print("", "", "", (" }")); | 1556 print("", "", "", (" }")); |
| 1556 end | 1557 end |
| 1557 end | 1558 end |
| 1558 end | 1559 end |
| 1560 if feature.meta then | |
| 1561 for k, v in it.sorted_pairs(feature.meta) do | |
| 1562 print("", "", (" - %s: %s"):format(k, v)); | |
| 1563 end | |
| 1564 end | |
| 1559 print(""); | 1565 print(""); |
| 1560 end | 1566 end |
| 1561 | 1567 |
| 1562 local all_ok = true; | 1568 local all_ok = true; |
| 1563 | 1569 |
| 1640 end | 1646 end |
| 1641 if not found then | 1647 if not found then |
| 1642 current_feature.lacking_components = current_feature.lacking_components or {}; | 1648 current_feature.lacking_components = current_feature.lacking_components or {}; |
| 1643 table.insert(current_feature.lacking_components, suggested); | 1649 table.insert(current_feature.lacking_components, suggested); |
| 1644 end | 1650 end |
| 1651 return found; | |
| 1645 end | 1652 end |
| 1646 | 1653 |
| 1647 local features = { | 1654 local features = { |
| 1648 { | 1655 { |
| 1649 name = "Basic functionality"; | 1656 name = "Basic functionality"; |
| 1714 ); | 1721 ); |
| 1715 end; | 1722 end; |
| 1716 }; | 1723 }; |
| 1717 { | 1724 { |
| 1718 name = "File sharing"; | 1725 name = "File sharing"; |
| 1719 check = function () | |
| 1720 check_component("http_file_share", "http_upload", "http_upload_external"); | |
| 1721 desc = "Sharing of files to groups and offline users"; | 1726 desc = "Sharing of files to groups and offline users"; |
| 1727 check = function (self) | |
| 1728 local service = check_component("http_file_share", "http_upload", "http_upload_external"); | |
| 1729 if service then | |
| 1730 local size_limit; | |
| 1731 if api(service):get_option("component_module") == "http_file_share" then | |
| 1732 size_limit = api(service):get_option_number("http_file_share_size_limit", 10*1024*1024); | |
| 1733 end | |
| 1734 if size_limit then | |
| 1735 self.meta = { | |
| 1736 ["Size limit"] = human_units.format(size_limit, "b", "b"); | |
| 1737 }; | |
| 1738 end | |
| 1739 end | |
| 1722 end; | 1740 end; |
| 1723 }; | 1741 }; |
| 1724 { | 1742 { |
| 1725 name = "Group chats"; | 1743 name = "Group chats"; |
| 1726 desc = "Create group chats and channels"; | 1744 desc = "Create group chats and channels"; |
| 1734 print(host); | 1752 print(host); |
| 1735 end | 1753 end |
| 1736 | 1754 |
| 1737 for _, feature in ipairs(features) do | 1755 for _, feature in ipairs(features) do |
| 1738 current_feature = feature; | 1756 current_feature = feature; |
| 1739 feature.check(); | 1757 feature:check(); |
| 1740 feature.ok = ( | 1758 feature.ok = ( |
| 1741 not feature.lacking_modules and | 1759 not feature.lacking_modules and |
| 1742 not feature.lacking_components and | 1760 not feature.lacking_components and |
| 1743 not feature.lacking_component_modules | 1761 not feature.lacking_component_modules |
| 1744 ); | 1762 ); |
