From f3c822cc1520720a4bb63e3c610076571d90b520 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 21 Feb 2011 15:52:12 -0800 Subject: [PATCH] Ticket #3011: Add attachments/uploads and attachments/file_quota to api/statusnet/config.(xml|json) file_quota is adjusted from the defined value to take into account the maximum upload size limits in PHP, or cropped to 0 if uploads are disabled. This can be used by client apps to determine maximum size for an attachment. --- actions/apistatusnetconfig.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/actions/apistatusnetconfig.php b/actions/apistatusnetconfig.php index 771a95baec..b34c6cc544 100644 --- a/actions/apistatusnetconfig.php +++ b/actions/apistatusnetconfig.php @@ -59,7 +59,8 @@ class ApiStatusnetConfigAction extends ApiAction 'notice' => array('contentlimit'), 'throttle' => array('enabled', 'count', 'timespan'), 'xmpp' => array('enabled', 'server', 'port', 'user'), - 'integration' => array('source') + 'integration' => array('source'), + 'attachments' => array('uploads', 'file_quota') ); /** @@ -96,7 +97,7 @@ class ApiStatusnetConfigAction extends ApiAction foreach ($this->keys as $section => $settings) { $this->elementStart($section); foreach ($settings as $setting) { - $value = common_config($section, $setting); + $value = $this->setting($section, $setting); if (is_array($value)) { $value = implode(',', $value); } else if ($value === false || $value == '0') { @@ -125,7 +126,7 @@ class ApiStatusnetConfigAction extends ApiAction $result[$section] = array(); foreach ($settings as $setting) { $result[$section][$setting] - = common_config($section, $setting); + = $this->setting($section, $setting); } } $this->initDocument('json'); @@ -143,6 +144,20 @@ class ApiStatusnetConfigAction extends ApiAction } } + function setting($section, $key) { + $result = common_config($section, $key); + if ($key == 'file_quota') { + // hack: adjust for the live upload limit + if (common_config($section, 'uploads')) { + $max = ImageFile::maxFileSizeInt(); + } else { + $max = 0; + } + return min($result, $max); + } + return $result; + } + /** * Return true if read only. *