# HG changeset patch
# Node ID 017794b4aa5dac743beb8256844d510b21976073
# Parent  58687db710b539ed03c068461bbc27b443f2d205
diff --git a/libpurple/purplenotificationauthorizationrequest.c b/libpurple/purplenotificationauthorizationrequest.c
--- a/libpurple/purplenotificationauthorizationrequest.c
+++ b/libpurple/purplenotificationauthorizationrequest.c
@@ -97,6 +97,10 @@
 			g_signal_connect_object(contact, "notify::name-for-display",
 			                        G_CALLBACK(purple_notification_authorization_request_notify_cb),
 			                        notification, G_CONNECT_DEFAULT);
+
+			g_object_bind_property(request, "message",
+			                       notification, "subtitle",
+			                       G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
 		}
 
 		purple_notification_set_account(PURPLE_NOTIFICATION(notification),
diff --git a/protocols/demo/purpledemoprotocolactions.c b/protocols/demo/purpledemoprotocolactions.c
--- a/protocols/demo/purpledemoprotocolactions.c
+++ b/protocols/demo/purpledemoprotocolactions.c
@@ -508,6 +508,55 @@
 	g_clear_object(&account);
 }
 
+static const char *auth_request_ids[] = {"chuck", "eve", "mallory", "michael"};
+
+static void
+purple_demo_protocol_authorization_request(G_GNUC_UNUSED GSimpleAction *action,
+                                           GVariant *parameter,
+                                           G_GNUC_UNUSED gpointer data)
+{
+	PurpleAccount *account = NULL;
+	PurpleAccountManager *account_manager = NULL;
+	PurpleAuthorizationRequest *request = NULL;
+	PurpleContact *contact = NULL;
+	PurpleContactManager *contact_manager = NULL;
+	PurpleNotification *notification = NULL;
+	PurpleNotificationManager *notification_manager = NULL;
+	PurpleTags *tags = NULL;
+	const char *account_id = NULL;
+	const char *message = NULL;
+	static guint counter = 0;
+
+	account_id = g_variant_get_string(parameter, NULL);
+	account_manager = purple_account_manager_get_default();
+	account = purple_account_manager_find_by_id(account_manager, account_id);
+
+	contact_manager = purple_contact_manager_get_default();
+	contact = purple_contact_manager_find_with_id(contact_manager, account,
+	                                              auth_request_ids[counter]);
+
+	tags = purple_contact_info_get_tags(PURPLE_CONTACT_INFO(contact));
+	message = purple_tags_get(tags, "auth-request-msg");
+
+	request = purple_authorization_request_new(contact);
+	if(!purple_strempty(message)) {
+		purple_authorization_request_set_message(request, message);
+	}
+
+	notification = purple_notification_authorization_request_new(NULL,
+	                                                             request);
+	notification_manager = purple_notification_manager_get_default();
+	purple_notification_manager_add(notification_manager, notification);
+
+	counter++;
+	if(counter >= G_N_ELEMENTS(auth_request_ids)) {
+		counter = 0;
+	}
+
+	g_clear_object(&notification);
+	g_clear_object(&account);
+}
+
 /******************************************************************************
  * Helpers
  *****************************************************************************/
@@ -532,6 +581,10 @@
 			.activate = purple_demo_protocol_remote_add,
 			.parameter_type = "s",
 		}, {
+			.name = "authorization-request",
+			.activate = purple_demo_protocol_authorization_request,
+			.parameter_type = "s",
+		}, {
 			.name = "request-fields",
 			.activate = purple_demo_protocol_request_fields_activate,
 			.parameter_type = "s",
@@ -581,6 +634,13 @@
 	g_menu_append_item(menu, item);
 	g_object_unref(item);
 
+	item = g_menu_item_new(_("Trigger a contact authorization request"),
+	                       "prpl-demo.authorization-request");
+	g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",
+	                          "account");
+	g_menu_append_item(menu, item);
+	g_object_unref(item);
+
 	item = g_menu_item_new(_("Request Fields"), "prpl-demo.request-fields");
 	g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",
 	                          "account");
diff --git a/protocols/demo/resources/contacts.json b/protocols/demo/resources/contacts.json
--- a/protocols/demo/resources/contacts.json
+++ b/protocols/demo/resources/contacts.json
@@ -130,4 +130,34 @@
 		"primitive": "do-not-disturb"
 	},
 	"username": "Erin"
+}, {
+	"id": "chuck",
+	"presence": {
+		"primitive": "available"
+	},
+	"username": "Chuck"
+}, {
+	"id": "eve",
+	"presence": {
+		"primitive": "invisible"
+	},
+	"tags": [
+		"auth-request-msg:Nice avatar!"
+	],
+	"username": "Eve"
+}, {
+	"id": "mallory",
+	"presence": {
+		"primitive": "offline"
+	},
+	"username": "Mallory"
+}, {
+	"id": "michael",
+	"presence": {
+		"primitive": "streaming"
+	},
+	"tags": [
+		"auth-request-msg:Hey come check out my stream!"
+	],
+	"username": "Michael"
 }]
