Skip to content
Snippets Groups Projects
Utils.cpp 36.1 KiB
Newer Older
                    break;

                auto user_id =
                  mtx::identifiers::parse<mtx::identifiers::User>(m.user_id.toStdString());

                auto server = user_id.hostname();
                if (std::find(begin(vias), end(vias), server) == vias.end())
                    vias.push_back(server);
            }
        }
    }

    if (vias.empty()) {
        auto parents = cache::client()->getParentRoomIds(roomid);
        for (const auto &p : parents) {
            auto child =
              cache::client()->getStateEvent<mtx::events::state::space::Child>(p, roomid);
            if (child && child->content.via)
                vias.insert(vias.end(), child->content.via->begin(), child->content.via->end());
        }

        std::sort(begin(vias), end(vias));
        auto last = std::unique(begin(vias), end(vias));
        vias.erase(last, end(vias));

        // if (vias.size()> 3)
        //     vias.erase(begin(vias)+3, end(vias));
    }
    return vias;
}