Compare commits

...

2 Commits

Author SHA1 Message Date
158860e1b0
allow specifying vgroup 2024-01-14 17:24:40 +01:00
759cd414ab
fix wrong id for subs 2024-01-14 17:13:31 +01:00

View File

@ -95,9 +95,24 @@ void Bridge::registerCommands(void) {
const auto contact_from = m.get<Message::Components::ContactFrom>().c; const auto contact_from = m.get<Message::Components::ContactFrom>().c;
const auto contact_to = m.get<Message::Components::ContactTo>().c; const auto contact_to = m.get<Message::Components::ContactTo>().c;
// TODO: if no vgroup name supplied
Contact3Handle group_contact; Contact3Handle group_contact;
const VirtualGroups* vg = nullptr;
if (!params.empty()) { // vgroup_name supplied
for (const auto& vg_it : _vgroups) {
if (vg_it.vg_name == params) {
vg = &vg_it;
break;
}
}
if (vg == nullptr) {
_rmm.sendText(
contact_from,
"The supplied vgroup name does not exist!"
);
return true;
}
} else {
if (/*is public ?*/ _c_to_vg.count({_cr, contact_to})) { if (/*is public ?*/ _c_to_vg.count({_cr, contact_to})) {
// message was sent public in group // message was sent public in group
group_contact = {_cr, contact_to}; group_contact = {_cr, contact_to};
@ -117,13 +132,16 @@ void Bridge::registerCommands(void) {
} }
assert(static_cast<bool>(group_contact)); assert(static_cast<bool>(group_contact));
const auto& vg = _vgroups.at(_c_to_vg.at(group_contact)); vg = &_vgroups.at(_c_to_vg.at(group_contact));
}
assert(vg != nullptr);
_rmm.sendText( _rmm.sendText(
contact_from, contact_from,
"Contacts online in other bridged group(s) in vgroup '" + vg.vg_name + "'" "Contacts online in other bridged group(s) in vgroup '" + vg->vg_name + "'"
); );
for (const auto& vgc : vg.contacts) { for (const auto& vgc : vg->contacts) {
if (vgc.c == group_contact) { if (vgc.c == group_contact) {
// skip self // skip self
continue; continue;
@ -152,7 +170,7 @@ void Bridge::registerCommands(void) {
" '" + " '" +
(_cr.all_of<Contact::Components::Name>(sub_c) ? _cr.get<Contact::Components::Name>(sub_c).name : "<unk>") + (_cr.all_of<Contact::Components::Name>(sub_c) ? _cr.get<Contact::Components::Name>(sub_c).name : "<unk>") +
"'" + "'" +
(_cr.all_of<Contact::Components::ID>(sub_c) ? " id:" + bin2hex(vgc.id) : "") (_cr.all_of<Contact::Components::ID>(sub_c) ? " id:" + bin2hex(_cr.get<Contact::Components::ID>(sub_c).data) : "")
); );
} }