More modern coding, stuff related to subscriptions

Also trying to use the newly implemented AlreadyFulfilledException
This commit is contained in:
Mikael Nordfeldth
2014-05-05 23:57:41 +02:00
parent b16d8cba1d
commit fc3125cf28
4 changed files with 30 additions and 30 deletions

View File

@@ -134,7 +134,11 @@ class UsersalmonAction extends SalmonAction
$oprofile = $this->ensureProfile();
if ($oprofile instanceof Ostatus_profile) {
common_log(LOG_INFO, sprintf('Canceling subscription from remote %s to local %s', $oprofile->getUri(), $this->user->getNickname()));
Subscription::cancel($oprofile->localProfile(), $this->user->getProfile());
try {
Subscription::cancel($oprofile->localProfile(), $this->user->getProfile());
} catch (AlreadyFulfilledException $e) {
common_debug('Subscription did not exist, so there was nothing to cancel');
}
} else {
common_log(LOG_ERR, "Can't cancel subscription from remote, didn't find the profile");
}

View File

@@ -195,7 +195,7 @@ class SalmonAction extends Action
function handleUpdateProfile()
{
$oprofile = Ostatus_profile::getActorProfile($this->activity);
if ($oprofile) {
if ($oprofile instanceof Ostatus_profile) {
common_log(LOG_INFO, "Got a profile-update ping from $oprofile->uri");
$oprofile->updateFromActivityObject($this->activity->actor);
} else {