- if ($mode != $profile->sub_state) {
- common_log(LOG_WARNING, __METHOD__ . ": bogus hub callback with bad mode \"$mode\" for feed $topic in state \"{$profile->sub_state}\"");
- throw new ServerException("Bogus hub callback: mode doesn't match subscription state.", 404);
+ if ($mode == 'subscribe') {
+ // We may get re-sub requests legitimately.
+ if ($feedsub->sub_state != 'subscribe' && $feedsub->sub_state != 'active') {
+ // TRANS: Client exception. %s is an invalid topic.
+ throw new ClientException(sprintf(_m('Unexpected subscribe request for %s.'),$topic), 404);
+ }
+ } else {
+ if ($feedsub->sub_state != 'unsubscribe') {
+ // TRANS: Client exception. %s is an invalid topic.
+ throw new ClientException(sprintf(_m('Unexpected unsubscribe request for %s.'),$topic), 404);
+ }