| 2240 | } |
| 2241 | |
| 2242 | void IcingaDB::SendAddedComment(const Comment::Ptr& comment) |
| 2243 | { |
| 2244 | if (comment->GetEntryType() != CommentUser || !GetActive()) |
| 2245 | return; |
| 2246 | |
| 2247 | auto checkable (comment->GetCheckable()); |
| 2248 | |
| 2249 | Host::Ptr host; |
| 2250 | Service::Ptr service; |
| 2251 | tie(host, service) = GetHostService(checkable); |
| 2252 | |
| 2253 | // Update the checkable state to so that the "last_comment_id" is correctly reflected. |
| 2254 | EnqueueConfigObject(checkable, icingadb::task_queue::FullState); |
| 2255 | |
| 2256 | RedisConnection::Query xAdd ({ |
| 2257 | "XADD", "icinga:history:stream:comment", "*", |
| 2258 | "comment_id", GetObjectIdentifier(comment), |
| 2259 | "environment_id", m_EnvironmentId, |
| 2260 | "host_id", GetObjectIdentifier(host), |
| 2261 | "entry_time", Convert::ToString(TimestampToMilliseconds(comment->GetEntryTime())), |
| 2262 | "author", Utility::ValidateUTF8(comment->GetAuthor()), |
| 2263 | "comment", Utility::ValidateUTF8(comment->GetText()), |
| 2264 | "entry_type", IcingaDB::CommentTypeToString(comment->GetEntryType()), |
| 2265 | "is_persistent", Convert::ToString((unsigned short)comment->GetPersistent()), |
| 2266 | "is_sticky", Convert::ToString((unsigned short)comment->GetSticky()), |
| 2267 | "event_id", CalcEventID("comment_add", comment), |
| 2268 | "event_type", "comment_add" |
| 2269 | }); |
| 2270 | |
| 2271 | if (service) { |
| 2272 | xAdd.emplace_back("object_type"); |
| 2273 | xAdd.emplace_back("service"); |
| 2274 | xAdd.emplace_back("service_id"); |
| 2275 | xAdd.emplace_back(GetObjectIdentifier(checkable)); |
| 2276 | } else { |
| 2277 | xAdd.emplace_back("object_type"); |
| 2278 | xAdd.emplace_back("host"); |
| 2279 | } |
| 2280 | |
| 2281 | auto endpoint (Endpoint::GetLocalEndpoint()); |
| 2282 | |
| 2283 | if (endpoint) { |
| 2284 | xAdd.emplace_back("endpoint_id"); |
| 2285 | xAdd.emplace_back(GetObjectIdentifier(endpoint)); |
| 2286 | } |
| 2287 | |
| 2288 | { |
| 2289 | auto expireTime (comment->GetExpireTime()); |
| 2290 | |
| 2291 | if (expireTime > 0) { |
| 2292 | xAdd.emplace_back("expire_time"); |
| 2293 | xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expireTime))); |
| 2294 | } |
| 2295 | } |
| 2296 | |
| 2297 | m_HistoryBulker.ProduceOne(std::move(xAdd)); |
| 2298 | } |
| 2299 |
no test coverage detected