| 189 | } |
| 190 | |
| 191 | void Comment::RemoveComment(const String& id, bool removedManually, const String& removedBy) |
| 192 | { |
| 193 | Comment::Ptr comment = Comment::GetByName(id); |
| 194 | |
| 195 | if (!comment || comment->GetPackage() != "_api") |
| 196 | return; |
| 197 | |
| 198 | Log(LogNotice, "Comment") |
| 199 | << "Removed comment '" << comment->GetName() << "' from object '" << comment->GetCheckable()->GetName() << "'."; |
| 200 | |
| 201 | if (removedManually) { |
| 202 | comment->SetRemovalInfo(removedBy, Utility::GetTime()); |
| 203 | } |
| 204 | |
| 205 | Array::Ptr errors = new Array(); |
| 206 | |
| 207 | if (!ConfigObjectUtility::DeleteObject(comment, false, errors, nullptr)) { |
| 208 | ObjectLock olock(errors); |
| 209 | for (String error : errors) { |
| 210 | Log(LogCritical, "Comment", error); |
| 211 | } |
| 212 | |
| 213 | BOOST_THROW_EXCEPTION(std::runtime_error("Could not remove comment.")); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | void Comment::SetRemovalInfo(const String& removedBy, double removeTime, const MessageOrigin::Ptr& origin) { |
| 218 | { |
nothing calls this directly
no test coverage detected