# HG changeset patch
# Node ID cea3c2471329d8ac8980ab1dcf0461b0952d2bf5
# Parent  fc235710664e2d34d81eb9b5ebf504dec8437b47
diff --git a/protocols/demo/purpledemoconnection.c b/protocols/demo/purpledemoconnection.c
--- a/protocols/demo/purpledemoconnection.c
+++ b/protocols/demo/purpledemoconnection.c
@@ -37,6 +37,12 @@
                                G_GNUC_UNUSED GError **error)
 {
 	PurpleAccount *account = purple_connection_get_account(connection);
+	PurpleContactInfo *info = purple_account_get_contact_info(account);
+	const char *username = NULL;
+
+	username = purple_account_get_username(account);
+	purple_contact_info_set_id(info, username);
+	purple_contact_info_set_username(info, username);
 
 	purple_connection_set_state(connection, PURPLE_CONNECTION_STATE_CONNECTED);
 
diff --git a/protocols/demo/purpledemoprotocolconversation.c b/protocols/demo/purpledemoprotocolconversation.c
--- a/protocols/demo/purpledemoprotocolconversation.c
+++ b/protocols/demo/purpledemoprotocolconversation.c
@@ -201,7 +201,7 @@
 	if(purple_conversation_is_dm(conversation)) {
 		PurpleAccount *account = NULL;
 		PurpleContact *contact = NULL;
-		PurpleContactInfo *info = NULL;
+		PurpleContactInfo *contact_info = NULL;
 		PurpleContactManager *manager = NULL;
 		PurpleConversationMembers *members = NULL;
 
@@ -211,25 +211,17 @@
 		manager = purple_contact_manager_get_default();
 
 		/* Check if this dm is with echo. */
-		contact = purple_contact_manager_find_with_username(manager, account,
-		                                                    "Echo");
-		info = PURPLE_CONTACT_INFO(contact);
-		if(purple_conversation_members_has_member(members, info, NULL)) {
+		contact = purple_contact_manager_find_with_id(manager, account,
+		                                              "echo");
+		contact_info = PURPLE_CONTACT_INFO(contact);
+		if(purple_conversation_members_has_member(members, contact_info, NULL))
+		{
 			PurpleDemoProtocolIMInfo *info = NULL;
-			PurpleMessageFlags flags;
-
-			flags = purple_message_get_flags(message);
-			flags &= ~PURPLE_MESSAGE_SEND;
-			flags |= PURPLE_MESSAGE_RECV;
+			const char *contents = purple_message_get_contents(message);
 
 			info = g_new(PurpleDemoProtocolIMInfo, 1);
 			info->conversation = g_object_ref(conversation);
-			info->message = g_object_new(
-				PURPLE_TYPE_MESSAGE,
-				"author", "Echo",
-				"flags", flags,
-				"contents", purple_message_get_contents(message),
-				NULL);
+			info->message = purple_message_new(contact_info, contents);
 
 			g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
 			                purple_demo_protocol_echo_im_cb, info,
@@ -237,15 +229,18 @@
 		}
 
 		/* Check if this dm is with aegina. */
-		contact = purple_contact_manager_find_with_username(manager, account,
-		                                                    "Aegina");
-		info = PURPLE_CONTACT_INFO(contact);
-		if(purple_conversation_members_has_member(members, info, NULL)) {
+		contact = purple_contact_manager_find_with_id(manager, account,
+		                                              "aegina");
+		contact_info = PURPLE_CONTACT_INFO(contact);
+		if(purple_conversation_members_has_member(members, contact_info, NULL))
+		{
 			PurpleDemoProtocolIMInfo *info = g_new(PurpleDemoProtocolIMInfo, 1);
-			const char *author = purple_message_get_author_name(message);
+			PurpleContactInfo *author = purple_message_get_author(message);
 			const char *contents = NULL;
+			const char *author_id = NULL;
 
-			if(purple_strequal(author, "Hades")) {
+			author_id = purple_contact_info_get_id(author);
+			if(purple_strequal(author_id, "hades")) {
 				contents = "🫥️";
 			} else {
 				/* TRANSLATORS: This is a reference to the Cap of Invisibility owned by
@@ -254,12 +249,7 @@
 			}
 
 			info->conversation = g_object_ref(conversation);
-			info->message = g_object_new(
-				PURPLE_TYPE_MESSAGE,
-				"author", author,
-				"contents", contents,
-				"flags", PURPLE_MESSAGE_SEND,
-				NULL);
+			info->message = purple_message_new(contact_info, contents);
 
 			g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, purple_demo_protocol_echo_im_cb,
 			                info, (GDestroyNotify)purple_demo_protocol_im_info_free);
