@@ -4282,7 +4282,7 @@ discord_process_dispatch(DiscordAccount *da, const gchar *type, JsonObject *data
42824282 }
42834283 }
42844284
4285- } else if (purple_strequal (type , "RELATIONSHIP_ADD" )) {
4285+ } else if (purple_strequal (type , "RELATIONSHIP_ADD" ) || purple_strequal ( type , "RELATIONSHIP_UPDATE" ) ) {
42864286 discord_create_relationship (da , data );
42874287 } else if (purple_strequal (type , "RELATIONSHIP_REMOVE" )) {
42884288 guint64 user_id = to_int (json_object_get_string_member (data , "id" ));
@@ -5157,11 +5157,21 @@ discord_friends_auth_accept(
51575157 DiscordUserInviteResponseStore * store = userdata ;
51585158 DiscordUser * user = store -> user ;
51595159 DiscordAccount * da = store -> da ;
5160+ gchar * postdata ;
5161+ JsonObject * data = json_object_new ();
5162+
5163+ json_object_set_int_member (data , "type ", 1 );
5164+ //TODO do we need one of these too?
5165+ //json_object_set_boolean_member(data, "from_friend_suggestion", TRUE);
5166+ //json_object_set_boolean_member(data, "confirm_stranger_request", TRUE);
5167+ postdata = json_object_to_string (data ) ;
51605168
51615169 gchar * url = g_strdup_printf ("https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships/%" G_GUINT64_FORMAT , user -> id );
5162- discord_fetch_url_with_method (da , "PUT ", url , NULL , NULL, NULL);
5170+ discord_fetch_url_with_method (da , "PUT ", url , postdata , NULL, NULL);
51635171 g_free (url );
51645172
5173+ g_free (postdata );
5174+ json_object_unref (data );
51655175 g_free (store );
51665176}
51675177
@@ -5176,8 +5186,8 @@ discord_friends_auth_reject(
51765186 DiscordUser * user = store -> user ;
51775187 DiscordAccount * da = store -> da ;
51785188
5179- gchar * url = g_strdup_printf ("https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships/%" G_GUINT64_FORMAT , user -> id );
5180- discord_fetch_url_with_method (da , "DELETE " , url , NULL , NULL , NULL );
5189+ gchar * url = g_strdup_printf ("https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships/%" G_GUINT64_FORMAT "/ignore" , user -> id );
5190+ discord_fetch_url_with_method (da , "PUT " , url , NULL , NULL , NULL );
51815191 g_free (url );
51825192
51835193 g_free (store );
@@ -5198,13 +5208,15 @@ discord_create_relationship(DiscordAccount *da, JsonObject *json)
51985208 gchar * merged_username = discord_create_fullname (user );
51995209
52005210 if (type == RELATIONSHIP_PENDING_INCOMING ) {
5201- /* request add */
5202- DiscordUserInviteResponseStore * store = g_new0 (DiscordUserInviteResponseStore , 1 );
5211+ if (!json_object_has_member (json , "should_notify" ) || json_object_get_boolean_member (json , "should_notify" )) {
5212+ /* request add */
5213+ DiscordUserInviteResponseStore * store = g_new0 (DiscordUserInviteResponseStore , 1 );
52035214
5204- store -> da = da ;
5205- store -> user = user ;
5215+ store -> da = da ;
5216+ store -> user = user ;
52065217
5207- purple_account_request_authorization (da -> account , merged_username , NULL , NULL , NULL , FALSE, discord_friends_auth_accept , discord_friends_auth_reject , store );
5218+ purple_account_request_authorization (da -> account , merged_username , NULL , user -> global_name , NULL , TRUE, discord_friends_auth_accept , discord_friends_auth_reject , store );
5219+ }
52085220 } else if (type == RELATIONSHIP_FRIEND ) {
52095221 /* buddy on list */
52105222 PurpleBuddy * buddy = purple_blist_find_buddy (da -> account , merged_username );
@@ -8420,15 +8432,16 @@ discord_add_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group
84208432 usersplit = g_strsplit_set (buddy_name , "#" , 2 );
84218433 data = json_object_new ();
84228434 json_object_set_string_member (data , "username" , g_strstrip (usersplit [0 ]));
8423- if (usersplit [1 ] && * usersplit [1 ]) {
8424- json_object_set_string_member (data , "discriminator" , g_strstrip ( usersplit [1 ]) );
8435+ if (usersplit [1 ] && * usersplit [1 ] && ! purple_strequal ( g_strstrip ( usersplit [ 1 ]), "0000" ) ) {
8436+ json_object_set_string_member (data , "discriminator" , usersplit [1 ]);
84258437 } else {
84268438 json_object_set_null_member (data , "discriminator" );
84278439 }
84288440
84298441 postdata = json_object_to_string (data );
84308442
8431- discord_fetch_url (da , "https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships" , postdata , discord_add_buddy_cb , buddy );
8443+ const gchar * url = "https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships" ;
8444+ discord_fetch_url_with_method (da , "POST" , url , postdata , discord_add_buddy_cb , buddy );
84328445
84338446 g_free (postdata );
84348447 g_strfreev (usersplit );
@@ -8838,7 +8851,7 @@ discord_unblock_user(PurpleConnection *pc, const char *who)
88388851 }
88398852
88408853 url = g_strdup_printf ("https://" DISCORD_API_SERVER "/api/" DISCORD_API_VERSION "/users/@me/relationships/%" G_GUINT64_FORMAT , user -> id );
8841- discord_fetch_url_with_method (da , "DELETE " , url , NULL , NULL , NULL );
8854+ discord_fetch_url_with_method (da , "PUT " , url , "{\"type\":1}" , NULL , NULL );
88428855 g_free (url );
88438856}
88448857
0 commit comments