mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Calendar event timeline feed should reflect invite changes better
Summary: Ref T7988, Calendar event timeline feed should better reflect invite changes. Test Plan: Create or edit calendar event, invite or remove users, save, timeline feed should correctly reflect added/removed invitees. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7988 Differential Revision: https://secure.phabricator.com/D12625
This commit is contained in:
parent
68c113832e
commit
69536ea3b9
1 changed files with 87 additions and 17 deletions
|
@ -36,9 +36,14 @@ final class PhabricatorCalendarEventTransaction
|
|||
case self::TYPE_STATUS:
|
||||
case self::TYPE_DESCRIPTION:
|
||||
case self::TYPE_CANCEL:
|
||||
case self::TYPE_INVITE:
|
||||
$phids[] = $this->getObjectPHID();
|
||||
break;
|
||||
case self::TYPE_INVITE:
|
||||
$new = $this->getNewValue();
|
||||
foreach ($new as $phid => $status) {
|
||||
$phids[] = $phid;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $phids;
|
||||
|
@ -96,7 +101,6 @@ final class PhabricatorCalendarEventTransaction
|
|||
$old,
|
||||
$new);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_START_DATE:
|
||||
if ($old) {
|
||||
return pht(
|
||||
|
@ -119,31 +123,103 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
break;
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
"%s updated the event's description.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case self::TYPE_CANCEL:
|
||||
if ($new) {
|
||||
return pht(
|
||||
'%s cancelled this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
} else {
|
||||
return pht(
|
||||
'%s reinstated this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
}
|
||||
case self::TYPE_INVITE:
|
||||
return pht(
|
||||
"%s updated the event's invitee list.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
}
|
||||
if (count($old) === 1
|
||||
&& count($new) === 1
|
||||
&& isset($old[$author_phid])) {
|
||||
// user joined/declined/accepted event themself
|
||||
$old_status = $old[$author_phid];
|
||||
$new_status = $new[$author_phid];
|
||||
|
||||
if ($old_status !== $new_status) {
|
||||
switch ($new_status) {
|
||||
case PhabricatorCalendarEventInvitee::STATUS_INVITED:
|
||||
$text = pht(
|
||||
'%s has joined this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
|
||||
$text = pht(
|
||||
'%s is attending this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
|
||||
case PhabricatorCalendarEventInvitee::STATUS_UNINVITED:
|
||||
$text = pht(
|
||||
'%s has declined this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
default:
|
||||
$text = pht(
|
||||
'%s has changed their status for this event.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// user changed status for many users
|
||||
$self_joined = null;
|
||||
$self_declined = null;
|
||||
$added = array();
|
||||
$uninvited = array();
|
||||
$text = null;
|
||||
|
||||
foreach ($new as $phid => $status) {
|
||||
if ($status == PhabricatorCalendarEventInvitee::STATUS_INVITED
|
||||
|| $status == PhabricatorCalendarEventInvitee::STATUS_ATTENDING) {
|
||||
// added users
|
||||
$added[] = $phid;
|
||||
} else if (
|
||||
$status == PhabricatorCalendarEventInvitee::STATUS_DECLINED
|
||||
|| $status == PhabricatorCalendarEventInvitee::STATUS_UNINVITED) {
|
||||
$uninvited[] = $phid;
|
||||
}
|
||||
}
|
||||
|
||||
$count_added = count($added);
|
||||
$count_uninvited = count($uninvited);
|
||||
$added_text = null;
|
||||
$uninvited_text = null;
|
||||
|
||||
if ($count_added > 0 && $count_uninvited == 0) {
|
||||
$added_text = $this->renderHandleList($added);
|
||||
$text = pht('%s invited: %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$added_text);
|
||||
} else if ($count_added > 0 && $count_uninvited > 0) {
|
||||
$added_text = $this->renderHandleList($added);
|
||||
$uninvited_text = $this->renderHandleList($uninvited);
|
||||
$text = pht('%s invited: %s and uninvited: %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$added_text,
|
||||
$uninvited_text);
|
||||
} else if ($count_added == 0 && $count_uninvited > 0) {
|
||||
$uninvited_text = $this->renderHandleList($uninvited);
|
||||
$text = pht('%s uninvited: %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$uninvited_text);
|
||||
} else {
|
||||
$text = pht('%s updated the invitee list.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
}
|
||||
return $text;
|
||||
break;
|
||||
}
|
||||
return parent::getTitle();
|
||||
}
|
||||
|
||||
|
@ -172,7 +248,6 @@ final class PhabricatorCalendarEventTransaction
|
|||
$old,
|
||||
$new);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_START_DATE:
|
||||
if ($old) {
|
||||
$old = phabricator_datetime($old, $viewer);
|
||||
|
@ -206,33 +281,28 @@ final class PhabricatorCalendarEventTransaction
|
|||
$this->renderHandleLink($object_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
break;
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
'%s updated the description of %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
case self::TYPE_CANCEL:
|
||||
if ($new) {
|
||||
return pht(
|
||||
'%s cancelled %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
} else {
|
||||
return pht(
|
||||
'%s reinstated %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
}
|
||||
case self::TYPE_INVITE:
|
||||
return pht(
|
||||
'%s updated the invitee list of %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitleForFeed();
|
||||
|
|
Loading…
Reference in a new issue