mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 18:08:26 +01:00
0a87881e98
Summary: This was mis-tested by only using one account, which could always see the image. External transaction moved file attachment to the modular transaction for file and audio instead. Test Plan: Test adding audio and a macro on a pleb account, visit with normal account and see macro fine. Reviewers: epriestley, amckinley Reviewed By: amckinley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17836
84 lines
1.9 KiB
PHP
84 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class PhabricatorMacroAudioTransaction
|
|
extends PhabricatorMacroTransactionType {
|
|
|
|
const TRANSACTIONTYPE = 'macro:audio';
|
|
|
|
public function generateOldValue($object) {
|
|
return $object->getAudioPHID();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setAudioPHID($value);
|
|
}
|
|
|
|
public function applyExternalEffects($object, $value) {
|
|
$old = $this->generateOldValue($object);
|
|
$new = $value;
|
|
$all = array();
|
|
if ($old) {
|
|
$all[] = $old;
|
|
}
|
|
if ($new) {
|
|
$all[] = $new;
|
|
}
|
|
|
|
$files = id(new PhabricatorFileQuery())
|
|
->setViewer($this->getActor())
|
|
->withPHIDs($all)
|
|
->execute();
|
|
$files = mpull($files, null, 'getPHID');
|
|
|
|
$old_file = idx($files, $old);
|
|
if ($old_file) {
|
|
$old_file->detachFromObject($object->getPHID());
|
|
}
|
|
|
|
$new_file = idx($files, $new);
|
|
if ($new_file) {
|
|
$new_file->attachToObject($object->getPHID());
|
|
}
|
|
}
|
|
|
|
public function getTitle() {
|
|
$new = $this->getNewValue();
|
|
$old = $this->getOldValue();
|
|
if (!$old) {
|
|
return pht(
|
|
'%s attached audio: %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderHandle($new));
|
|
} else {
|
|
return pht(
|
|
'%s changed the audio for this macro from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderHandle($old),
|
|
$this->renderHandle($new));
|
|
}
|
|
}
|
|
|
|
public function getTitleForFeed() {
|
|
$new = $this->getNewValue();
|
|
$old = $this->getOldValue();
|
|
if (!$old) {
|
|
return pht(
|
|
'%s attached audio to %s: %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderObject(),
|
|
$this->renderHandle($new));
|
|
} else {
|
|
return pht(
|
|
'%s changed the audio for %s from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderObject(),
|
|
$this->renderHandle($old),
|
|
$this->renderHandle($new));
|
|
}
|
|
}
|
|
|
|
public function getIcon() {
|
|
return 'fa-music';
|
|
}
|
|
|
|
}
|