3 final class HeraldWebhookURITransaction
4 extends HeraldWebhookTransactionType
{
6 const TRANSACTIONTYPE
= 'uri';
8 public function generateOldValue($object) {
9 return $object->getWebhookURI();
12 public function applyInternalEffects($object, $value) {
13 $object->setWebhookURI($value);
16 public function getTitle() {
18 '%s changed the URI for this webhook from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
26 '%s changed the URI for %s from %s to %s.',
27 $this->renderAuthor(),
28 $this->renderObject(),
29 $this->renderOldValue(),
30 $this->renderNewValue());
33 public function validateTransactions($object, array $xactions) {
35 $viewer = $this->getActor();
37 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
38 $errors[] = $this->newRequiredError(
39 pht('Webhooks must have a URI.'));
43 $max_length = $object->getColumnMaximumByteLength('webhookURI');
44 foreach ($xactions as $xaction) {
45 $old_value = $this->generateOldValue($object);
46 $new_value = $xaction->getNewValue();
48 $new_length = strlen($new_value);
49 if ($new_length > $max_length) {
50 $errors[] = $this->newInvalidError(
52 'Webhook URIs can be no longer than %s characters.',
53 new PhutilNumber($max_length)),
58 PhabricatorEnv
::requireValidRemoteURIForFetch(
64 } catch (Exception
$ex) {
65 $errors[] = $this->newInvalidError(