aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2016-01-14 22:05:03 +0100
committerMikael Nordfeldth <mmn@hethane.se>2016-01-14 22:05:03 +0100
commit8df38df5cb394e7631b5631e98340989a48afd76 (patch)
treefb3f88d9992436599f62684b50f1784b92b7bf23 /actions
parent16088d943959219c2d02aa40b3ef43f0e76c505e (diff)
downloadgnu-social-8df38df5cb394e7631b5631e98340989a48afd76.tar
gnu-social-8df38df5cb394e7631b5631e98340989a48afd76.zip
Get uploaded media_ids via File::getByID()
Filters out failed ones...
Diffstat (limited to 'actions')
-rw-r--r--actions/apistatusesupdate.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
index 0dc6a72279..8f381534c7 100644
--- a/actions/apistatusesupdate.php
+++ b/actions/apistatusesupdate.php
@@ -173,10 +173,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
if (preg_match_all('/\d+/', $this->trimmed('media_ids'), $matches) !== false) {
foreach (array_unique($matches[0]) as $match) {
try {
- $this->media_ids[$match] = true; // = File::getByID($match);
- } catch (Exception $e) {
- // Either $match was 0 (EmptyIdException) or File was not found (NoResultException)
- // Do we abort and report to the client?
+ $this->media_ids[$match] = File::getByID($match);
+ } catch (EmptyIdException $e) {
+ // got a zero from the client, at least Twidere does this on occasion
+ } catch (NoResultException $e) {
+ // File ID was not found. Do we abort and report to the client?
}
}
}
@@ -261,6 +262,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
foreach(array_keys($this->media_ids) as $media_id) {
// FIXME: Validation on this... Worst case is that if someone sends bad media_ids then
// we'll fill the notice with non-working links, so no real harm, done, but let's fix.
+ // The File objects are in the array, so we could get URLs from them directly.
$this->status .= ' ' . common_local_url('attachment', array('attachment' => $media_id));
}