# HG changeset patch
# Node ID 10e25eb8fdc02407c491c11e56444e217b07ea2d
# Parent  2f12cdef0048142b584a89a94ef389d71fb5deaa
diff --git a/libpurple/purplenotification.c b/libpurple/purplenotification.c
--- a/libpurple/purplenotification.c
+++ b/libpurple/purplenotification.c
@@ -28,6 +28,7 @@
 
 #include "purpleenums.h"
 #include "purplenotificationaddcontact.h"
+#include "purplenotificationauthorizationrequest.h"
 #include "util.h"
 
 typedef struct {
@@ -528,41 +529,11 @@
 PurpleNotification *
 purple_notification_new_from_authorization_request(PurpleAuthorizationRequest *authorization_request)
 {
-	PurpleAccount *account = NULL;
-	PurpleNotification *notification = NULL;
-	char *title = NULL;
-	const char *alias = NULL;
-	const char *username = NULL;
-
 	g_return_val_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(authorization_request),
 	                     NULL);
 
-	account = purple_authorization_request_get_account(authorization_request);
-	G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-	notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST,
-	                                       account, authorization_request,
-	                                       g_object_unref);
-	G_GNUC_END_IGNORE_DEPRECATIONS
-
-	username = purple_authorization_request_get_username(authorization_request);
-	alias = purple_authorization_request_get_alias(authorization_request);
-
-	if(alias != NULL && *alias != '\0') {
-		title = g_strdup_printf(_("%s (%s) would like to add %s to their"
-		                          " contact list"),
-		                        alias, username,
-		                        purple_account_get_username(account));
-	} else {
-		title = g_strdup_printf(_("%s would like to add %s to their contact"
-		                          " list"),
-		                        username,
-		                        purple_account_get_username(account));
-	}
-
-	purple_notification_set_title(notification, title);
-	g_free(title);
-
-	return notification;
+	return purple_notification_authorization_request_new(NULL,
+	                                                     authorization_request);
 }
 
 PurpleNotification *
diff --git a/libpurple/purplenotification.h b/libpurple/purplenotification.h
--- a/libpurple/purplenotification.h
+++ b/libpurple/purplenotification.h
@@ -165,7 +165,7 @@
  *
  * Since: 3.0
  */
-PURPLE_AVAILABLE_IN_3_0
+PURPLE_DEPRECATED_FOR(purple_notification_authorization_request_new)
 PurpleNotification *purple_notification_new_from_authorization_request(PurpleAuthorizationRequest *authorization_request);
 
 /**
diff --git a/libpurple/purplenotificationauthorizationrequest.c b/libpurple/purplenotificationauthorizationrequest.c
--- a/libpurple/purplenotificationauthorizationrequest.c
+++ b/libpurple/purplenotificationauthorizationrequest.c
@@ -85,16 +85,27 @@
 	g_return_if_fail(PURPLE_IS_NOTIFICATION_AUTHORIZATION_REQUEST(notification));
 
 	if(g_set_object(&notification->authorization_request, request)) {
+		PurpleAccount *account = NULL;
+		GObject *obj = G_OBJECT(notification);
+
+		g_object_freeze_notify(obj);
+
 		if(PURPLE_IS_AUTHORIZATION_REQUEST(request)) {
+			account = purple_authorization_request_get_account(request);
+
 			g_signal_connect_object(request, "notify",
 			                        G_CALLBACK(purple_notification_authorization_request_request_changed_cb),
 			                        notification, 0);
 
-			purple_notification_authorization_request_update(notification);
 		}
 
-		g_object_notify_by_pspec(G_OBJECT(notification),
-		                         properties[PROP_AUTHORIZATION_REQUEST]);
+		purple_notification_set_account(PURPLE_NOTIFICATION(notification),
+		                                account);
+
+		g_object_notify_by_pspec(obj, properties[PROP_AUTHORIZATION_REQUEST]);
+		g_object_thaw_notify(obj);
+
+		purple_notification_authorization_request_update(notification);
 	}
 }
 
@@ -117,6 +128,28 @@
                     PURPLE_TYPE_NOTIFICATION)
 
 static void
+purple_notification_authorization_request_constructed(GObject *obj) {
+	PurpleAccount *account = NULL;
+	PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
+
+	G_OBJECT_CLASS(purple_notification_authorization_request_parent_class)->constructed(obj);
+
+	account = purple_notification_get_account(notification);
+	if(!PURPLE_IS_ACCOUNT(account)) {
+		PurpleNotificationAuthorizationRequest *auth_notification = NULL;
+
+		auth_notification = PURPLE_NOTIFICATION_AUTHORIZATION_REQUEST(obj);
+
+		account = purple_authorization_request_get_account(auth_notification->authorization_request);
+
+		purple_notification_set_account(notification, account);
+	}
+
+	purple_notification_set_icon_name(notification,
+	                                  "address-book-new-symbolic");
+}
+
+static void
 purple_notification_authorization_request_finalize(GObject *object) {
 	PurpleNotificationAuthorizationRequest *notification = NULL;
 
@@ -179,6 +212,7 @@
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
+	obj_class->constructed = purple_notification_authorization_request_constructed;
 	obj_class->finalize = purple_notification_authorization_request_finalize;
 	obj_class->get_property = purple_notification_authorization_request_get_property;
 	obj_class->set_property = purple_notification_authorization_request_set_property;
@@ -203,18 +237,15 @@
  * Public API
  *****************************************************************************/
 PurpleNotification *
-purple_notification_authorization_request_new(PurpleAuthorizationRequest *request)
+purple_notification_authorization_request_new(const char *id,
+                                              PurpleAuthorizationRequest *request)
 {
-	PurpleAccount *account = NULL;
-
 	g_return_val_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(request), NULL);
 
-	account = purple_authorization_request_get_account(request);
-
 	return g_object_new(
 	    PURPLE_TYPE_NOTIFICATION_AUTHORIZATION_REQUEST,
-	    "account", account,
 	    "authorization-request", request,
+	    "id", id,
 	    NULL);
 }
 
diff --git a/libpurple/purplenotificationauthorizationrequest.h b/libpurple/purplenotificationauthorizationrequest.h
--- a/libpurple/purplenotificationauthorizationrequest.h
+++ b/libpurple/purplenotificationauthorizationrequest.h
@@ -54,16 +54,20 @@
 
 /**
  * purple_notification_authorization_request_new:
+ * @id: (nullable): An identifier for the notification.
  * @request: The authorization request instance.
  *
  * Creates a new [class@Notification] for @request.
  *
+ * Since [class@AuthorizationRequest] has a [class@Account],
+ * [property@Notification:account] will automatically be set to that.
+ *
  * Returns: The new notification.
  *
  * Since: 3.0
  */
 PURPLE_AVAILABLE_IN_3_0
-PurpleNotification *purple_notification_authorization_request_new(PurpleAuthorizationRequest *request);
+PurpleNotification *purple_notification_authorization_request_new(const char *id, PurpleAuthorizationRequest *request);
 
 /**
  * purple_notification_authorization_request_get_request:
diff --git a/libpurple/tests/test_notification_authorization_request.c b/libpurple/tests/test_notification_authorization_request.c
--- a/libpurple/tests/test_notification_authorization_request.c
+++ b/libpurple/tests/test_notification_authorization_request.c
@@ -42,15 +42,26 @@
 test_purple_notification_authorization_request_new(void) {
 	PurpleAccount *account = NULL;
 	PurpleAuthorizationRequest *request = NULL;
+	PurpleAuthorizationRequest *request1 = NULL;
 	PurpleNotification *notification = NULL;
+	PurpleNotificationAuthorizationRequest *auth_notification = NULL;
+	const char *id = NULL;
 
 	account = purple_account_new("test", "test");
 	request = purple_authorization_request_new(account, "remote-username");
-	notification = purple_notification_authorization_request_new(request);
+	notification = purple_notification_authorization_request_new("id",
+	                                                             request);
 
 	g_assert_true(PURPLE_IS_NOTIFICATION(notification));
 	g_assert_true(PURPLE_IS_NOTIFICATION_AUTHORIZATION_REQUEST(notification));
 
+	id = purple_notification_get_id(PURPLE_NOTIFICATION(notification));
+	g_assert_cmpstr(id, ==, "id");
+
+	auth_notification = PURPLE_NOTIFICATION_AUTHORIZATION_REQUEST(notification);
+	request1 = purple_notification_authorization_request_get_request(auth_notification);
+	g_assert_true(request1 == request);
+
 	g_assert_finalize_object(notification);
 
 	g_clear_object(&request);
@@ -60,27 +71,37 @@
 static void
 test_purple_notification_authorization_request_properties(void) {
 	PurpleAccount *account = NULL;
+	PurpleAccount *account1 = NULL;
 	PurpleAuthorizationRequest *request = NULL;
 	PurpleAuthorizationRequest *request1 = NULL;
 	PurpleNotification *notification = NULL;
+	char *id = NULL;
 
 	account = purple_account_new("test", "test");
 	request = purple_authorization_request_new(account, "username");
 
 	notification = g_object_new(
 		PURPLE_TYPE_NOTIFICATION_AUTHORIZATION_REQUEST,
-		"account", account,
 		"authorization-request", request,
+		"id", "id1",
 		NULL);
 
 	g_object_get(
 		notification,
+		"account", &account1,
 		"authorization-request", &request1,
+		"id", &id,
 		NULL);
 
+	g_assert_true(account1 == account);
+	g_clear_object(&account1);
+
 	g_assert_true(request1 == request);
 	g_clear_object(&request1);
 
+	g_assert_cmpstr(id, ==, "id1");
+	g_clear_pointer(&id, g_free);
+
 	g_assert_finalize_object(notification);
 
 	g_clear_object(&request);
@@ -97,7 +118,8 @@
 	account = purple_account_new("test", "test");
 	request = purple_authorization_request_new(account, "remote-username");
 
-	notification = purple_notification_authorization_request_new(request);
+	notification = purple_notification_authorization_request_new(NULL,
+	                                                             request);
 	g_signal_connect(notification, "notify::title",
 	                 G_CALLBACK(test_purple_notification_authorization_request_notify_cb),
 	                 &counter);
