+
+ function onStartHandleFeedEntry($activity)
+ {
+ return $this->_checkActivity($activity);
+ }
+
+ function onStartHandleSalmon($activity)
+ {
+ return $this->_checkActivity($activity);
+ }
+
+ function _checkActivity($activity)
+ {
+ $actor = $activity->actor;
+
+ if (empty($actor)) {
+ return true;
+ }
+
+ $homepage = strtolower($actor->link);
+
+ if (!empty($homepage)) {
+ if (!$this->_checkUrl($homepage)) {
+ // TRANS: Exception thrown trying to post a notice while having set a blocked homepage URL. %s is the blocked URL.
+ $msg = sprintf(_m("Users from \"%s\" are blocked."),
+ $homepage);
+ throw new ClientException($msg);
+ }
+ }
+
+ if (!empty($actor->poco)) {
+ $nickname = strtolower($actor->poco->preferredUsername);
+
+ if (!empty($nickname)) {
+ if (!$this->_checkNickname($nickname)) {
+ // TRANS: Exception thrown trying to post a notice while having a blocked nickname. %s is the blocked nickname.
+ $msg = sprintf(_m("Notices from nickname \"%s\" are disallowed."),
+ $nickname);
+ throw new ClientException($msg);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Check URLs and homepages for blacklisted users.
+ */
+ function onStartSubscribe(Profile $subscriber, Profile $other)
+ {
+ foreach (array($other->profileurl, $other->homepage) as $url) {
+
+ if (empty($url)) {
+ continue;
+ }
+
+ $url = strtolower($url);
+
+ if (!$this->_checkUrl($url)) {
+ // TRANS: Client exception thrown trying to subscribe to a person with a blocked homepage or site URL. %s is the blocked URL.
+ $msg = sprintf(_m("Users from \"%s\" are blocked."),
+ $url);
+ throw new ClientException($msg);
+ }
+ }
+
+ $nickname = $other->nickname;
+
+ if (!empty($nickname)) {
+ if (!$this->_checkNickname($nickname)) {
+ // TRANS: Client exception thrown trying to subscribe to a person with a blocked nickname. %s is the blocked nickname.
+ $msg = sprintf(_m("Cannot subscribe to nickname \"%s\"."),
+ $nickname);
+ throw new ClientException($msg);
+ }
+ }
+
+ return true;
+ }