forked from OpenGamers/abaddon
remove ability to create dms
This commit is contained in:
parent
96ec5bb665
commit
a4c8a2290d
@ -389,6 +389,7 @@ void Abaddon::ShowUserMenu(const GdkEvent *event, Snowflake id, Snowflake guild_
|
||||
|
||||
for (const auto child : m_user_menu_roles_submenu->get_children())
|
||||
delete child;
|
||||
|
||||
if (guild.has_value() && user.has_value()) {
|
||||
const auto roles = user->GetSortedRoles();
|
||||
m_user_menu_roles->set_visible(!roles.empty());
|
||||
@ -411,7 +412,7 @@ void Abaddon::ShowUserMenu(const GdkEvent *event, Snowflake id, Snowflake guild_
|
||||
if (me == id) {
|
||||
m_user_menu_ban->set_visible(false);
|
||||
m_user_menu_kick->set_visible(false);
|
||||
m_user_menu_open_dm->set_visible(false);
|
||||
m_user_menu_open_dm->set_sensitive(false);
|
||||
} else {
|
||||
const bool has_kick = m_discord.HasGuildPermission(me, guild_id, Permission::KICK_MEMBERS);
|
||||
const bool has_ban = m_discord.HasGuildPermission(me, guild_id, Permission::BAN_MEMBERS);
|
||||
@ -419,7 +420,7 @@ void Abaddon::ShowUserMenu(const GdkEvent *event, Snowflake id, Snowflake guild_
|
||||
|
||||
m_user_menu_kick->set_visible(has_kick && can_manage);
|
||||
m_user_menu_ban->set_visible(has_ban && can_manage);
|
||||
m_user_menu_open_dm->set_visible(true);
|
||||
m_user_menu_open_dm->set_sensitive(m_discord.FindDM(id).has_value());
|
||||
}
|
||||
|
||||
m_user_menu_remove_recipient->hide();
|
||||
@ -467,7 +468,7 @@ void Abaddon::SetupUserMenu() {
|
||||
m_user_menu_ban = Gtk::manage(new Gtk::MenuItem("Ban"));
|
||||
m_user_menu_kick = Gtk::manage(new Gtk::MenuItem("Kick"));
|
||||
m_user_menu_copy_id = Gtk::manage(new Gtk::MenuItem("Copy ID"));
|
||||
m_user_menu_open_dm = Gtk::manage(new Gtk::MenuItem("Open DM"));
|
||||
m_user_menu_open_dm = Gtk::manage(new Gtk::MenuItem("Go to DM"));
|
||||
m_user_menu_roles = Gtk::manage(new Gtk::MenuItem("Roles"));
|
||||
m_user_menu_info = Gtk::manage(new Gtk::MenuItem("View Profile"));
|
||||
m_user_menu_remove_recipient = Gtk::manage(new Gtk::MenuItem("Remove From Group"));
|
||||
@ -578,18 +579,9 @@ void Abaddon::on_user_menu_copy_id() {
|
||||
|
||||
void Abaddon::on_user_menu_open_dm() {
|
||||
const auto existing = m_discord.FindDM(m_shown_user_menu_id);
|
||||
if (existing.has_value())
|
||||
if (existing.has_value()) {
|
||||
ActionChannelOpened(*existing);
|
||||
else
|
||||
m_discord.CreateDM(m_shown_user_menu_id, [this](DiscordError code, Snowflake channel_id) {
|
||||
if (code == DiscordError::NONE) {
|
||||
// give the gateway a little window to send CHANNEL_CREATE
|
||||
auto cb = [this, channel_id] {
|
||||
ActionChannelOpened(channel_id);
|
||||
};
|
||||
Glib::signal_timeout().connect_once(sigc::track_obj(cb, *this), 200);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Abaddon::on_user_menu_remove_recipient() {
|
||||
|
@ -552,19 +552,6 @@ void DiscordClient::UpdateStatus(PresenceStatus status, bool is_afk, const Activ
|
||||
m_signal_presence_update.emit(GetUserData(), status);
|
||||
}
|
||||
|
||||
void DiscordClient::CreateDM(Snowflake user_id, const sigc::slot<void(DiscordError code, Snowflake channel_id)> &callback) {
|
||||
CreateDMObject obj;
|
||||
obj.Recipients.push_back(user_id);
|
||||
m_http.MakePOST("/users/@me/channels", nlohmann::json(obj).dump(), [callback](const http::response &response) {
|
||||
if (!CheckCode(response)) {
|
||||
callback(DiscordError::NONE, Snowflake::Invalid);
|
||||
return;
|
||||
}
|
||||
auto channel = nlohmann::json::parse(response.text).get<ChannelData>();
|
||||
callback(GetCodeFromResponse(response), channel.ID);
|
||||
});
|
||||
}
|
||||
|
||||
void DiscordClient::CloseDM(Snowflake channel_id) {
|
||||
m_http.MakeDELETE("/channels/" + std::to_string(channel_id), [](const http::response &response) {
|
||||
CheckCode(response);
|
||||
|
@ -116,7 +116,6 @@ public:
|
||||
void BanUser(Snowflake user_id, Snowflake guild_id); // todo: reason, delete messages
|
||||
void UpdateStatus(PresenceStatus status, bool is_afk);
|
||||
void UpdateStatus(PresenceStatus status, bool is_afk, const ActivityData &obj);
|
||||
void CreateDM(Snowflake user_id, const sigc::slot<void(DiscordError code, Snowflake channel_id)> &callback);
|
||||
void CloseDM(Snowflake channel_id);
|
||||
std::optional<Snowflake> FindDM(Snowflake user_id); // wont find group dms
|
||||
void AddReaction(Snowflake id, Glib::ustring param);
|
||||
|
Loading…
Reference in New Issue
Block a user