diff --git a/include/ircd/m/room.h b/include/ircd/m/room.h index 0a5277dbf..30286cc4c 100644 --- a/include/ircd/m/room.h +++ b/include/ircd/m/room.h @@ -360,6 +360,7 @@ struct ircd::m::room::head bool for_each(const closure_bool &) const; void for_each(const closure &) const; + bool has(const event::id &) const; size_t count() const; head(const m::room &room) diff --git a/ircd/m/room.cc b/ircd/m/room.cc index 95cfb7102..6ecc5d5f7 100644 --- a/ircd/m/room.cc +++ b/ircd/m/room.cc @@ -1510,6 +1510,21 @@ const return ret; } +bool +ircd::m::room::head::has(const event::id &event_id) +const +{ + bool ret{false}; + for_each(closure_bool{[&ret, &event_id] + (const event::idx &event_idx, const event::id &event_id_) + { + ret = event_id_ == event_id; + return !ret; // for_each protocol: false to break + }}); + + return ret; +} + void ircd::m::room::head::for_each(const closure &closure) const