Don't do saveKnownReplies unless it's a verb=post

This commit is contained in:
Mikael Nordfeldth 2015-12-31 02:31:35 +01:00
parent 66289d3e76
commit 7cf6aaecd0

View File

@ -685,30 +685,33 @@ class Notice extends Managed_DataObject
// Clear the cache for subscribed users, so they'll update at next request // Clear the cache for subscribed users, so they'll update at next request
// XXX: someone clever could prepend instead of clearing the cache // XXX: someone clever could prepend instead of clearing the cache
// Save per-notice metadata... // Only save 'attention' and metadata stuff (URLs, tags...) stuff if
// the activityverb is a POST (since stuff like repeat, favorite etc.
// reasonably handle notifications themselves.
if (ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST))) {
if (isset($replies)) {
$notice->saveKnownReplies($replies);
} else {
$notice->saveReplies();
}
if (isset($replies)) { if (isset($tags)) {
$notice->saveKnownReplies($replies); $notice->saveKnownTags($tags);
} else { } else {
$notice->saveReplies(); $notice->saveTags();
} }
if (isset($tags)) { // Note: groups may save tags, so must be run after tags are saved
$notice->saveKnownTags($tags); // to avoid errors on duplicates.
} else { // Note: groups should always be set.
$notice->saveTags();
}
// Note: groups may save tags, so must be run after tags are saved $notice->saveKnownGroups($groups);
// to avoid errors on duplicates.
// Note: groups should always be set.
$notice->saveKnownGroups($groups); if (isset($urls)) {
$notice->saveKnownUrls($urls);
if (isset($urls)) { } else {
$notice->saveKnownUrls($urls); $notice->saveUrls();
} else { }
$notice->saveUrls();
} }
if ($distribute) { if ($distribute) {
@ -965,28 +968,33 @@ class Notice extends Managed_DataObject
// Used primarily for OStatus (and if we don't federate, all attentions would be local anyway) // Used primarily for OStatus (and if we don't federate, all attentions would be local anyway)
Event::handle('GetLocalAttentions', array($actor, $act->context->attention, &$mentions, &$group_ids)); Event::handle('GetLocalAttentions', array($actor, $act->context->attention, &$mentions, &$group_ids));
if (!empty($mentions)) { // Only save 'attention' and metadata stuff (URLs, tags...) stuff if
$stored->saveKnownReplies($mentions); // the activityverb is a POST (since stuff like repeat, favorite etc.
} else { // reasonably handle notifications themselves.
$stored->saveReplies(); if (ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST))) {
} if (!empty($mentions)) {
$stored->saveKnownReplies($mentions);
} else {
$stored->saveReplies();
}
if (!empty($tags)) { if (!empty($tags)) {
$stored->saveKnownTags($tags); $stored->saveKnownTags($tags);
} else { } else {
$stored->saveTags(); $stored->saveTags();
} }
// Note: groups may save tags, so must be run after tags are saved // Note: groups may save tags, so must be run after tags are saved
// to avoid errors on duplicates. // to avoid errors on duplicates.
// Note: groups should always be set. // Note: groups should always be set.
$stored->saveKnownGroups($group_ids); $stored->saveKnownGroups($group_ids);
if (!empty($urls)) { if (!empty($urls)) {
$stored->saveKnownUrls($urls); $stored->saveKnownUrls($urls);
} else { } else {
$stored->saveUrls(); $stored->saveUrls();
}
} }
if ($distribute) { if ($distribute) {
@ -1615,12 +1623,6 @@ class Notice extends Managed_DataObject
function saveReplies() function saveReplies()
{ {
// Don't save reply data for repeats
if ($this->isRepeat()) {
return array();
}
$sender = $this->getProfile(); $sender = $this->getProfile();
$replied = array(); $replied = array();