Skip to content

Commit 1b91cc4

Browse files
committed
Don't spam ourselves with popups about other users being accepted/rejected into a server
1 parent f60596c commit 1b91cc4

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

libdiscord.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,27 +4657,33 @@ discord_process_dispatch(DiscordAccount *da, const gchar *type, JsonObject *data
46574657
if (!guild) {
46584658
return;
46594659
}
4660-
const gchar *status = json_object_get_string_member(data, "status");
4661-
if (purple_strequal(status, "APPROVED")) {
4662-
info = g_strdup_printf(_("Your request to join the server %s has been approved!"), guild->name);
4663-
} else {
4664-
JsonObject *request = json_object_get_object_member(data, "request");
4665-
const gchar *rejection_reason = json_object_get_string_member(request, "rejection_reason");
4666-
if (rejection_reason == NULL) {
4667-
// Probably pending
4668-
info = g_strdup_printf(_("Your request to join the server %s is currently pending. You will be notified of any updates regarding your request."), guild->name);
4660+
JsonObject *request = json_object_get_object_member(data, "request");
4661+
guint64 user_id = json_object_get_int_member(request, "user_id");
4662+
if (user_id == da->self_user_id) {
4663+
// We only care about our own requests
4664+
const gchar *status = json_object_get_string_member(data, "status");
4665+
if (purple_strequal(status, "APPROVED")) {
4666+
info = g_strdup_printf(_("Your request to join the server %s has been approved!"), guild->name);
46694667
} else {
4670-
info = g_strdup_printf(_("Your request to join the server %s was rejected. The reason given was:\n\n%s"), guild->name, rejection_reason);
4668+
const gchar *rejection_reason = json_object_get_string_member(request, "rejection_reason");
4669+
if (rejection_reason == NULL) {
4670+
// Probably pending
4671+
info = g_strdup_printf(_("Your request to join the server %s is currently pending. You will be notified of any updates regarding your request."), guild->name);
4672+
} else {
4673+
info = g_strdup_printf(_("Your request to join the server %s was rejected. The reason given was:\n\n%s"), guild->name, rejection_reason);
4674+
}
46714675
}
46724676
}
46734677

4674-
purple_notify_info(
4675-
da->pc,
4676-
_("Server Join Request Update"),
4677-
guild->name,
4678-
info
4679-
);
4680-
g_free(info);
4678+
if (info != NULL) {
4679+
purple_notify_info(
4680+
da->pc,
4681+
_("Server Join Request Update"),
4682+
guild->name,
4683+
info
4684+
);
4685+
g_free(info);
4686+
}
46814687

46824688
} else if (purple_strequal(type, "CHANNEL_RECIPIENT_ADD") || purple_strequal(type, "CHANNEL_RECIPIENT_REMOVE")) {
46834689
DiscordUser *user = discord_upsert_user(da->new_users, json_object_get_object_member(data, "user"));

0 commit comments

Comments
 (0)