[polari/wip/fmuellner/tracker: 327/335] telepathyClient: Log messages to tracker
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/tracker: 327/335] telepathyClient: Log messages to tracker
- Date: Sun, 24 Feb 2019 12:59:42 +0000 (UTC)
commit 558d829ed0683402a68ac4ee0095f09cae4c5c1e
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Jul 26 21:32:00 2017 +0200
telepathyClient: Log messages to tracker
src/telepathyClient.js | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 71b6bc8..8fca9ab 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -504,6 +504,8 @@ class TelepathyClient extends Tp.BaseClient {
return;
}
+ channel.connect('message-sent',
+ this._onMessageSent.bind(this));
channel.connect('message-received',
this._onMessageReceived.bind(this));
channel.connect('pending-message-removed',
@@ -591,7 +593,34 @@ class TelepathyClient extends Tp.BaseClient {
this._app.send_notification(this._getIdentifyNotificationID(accountPath), notification);
}
+ _logMessage(tpMessage, channel) {
+ let connection = Polari.util_get_tracker_connection ();
+
+ let accountId = channel.connection.get_account().get_path_suffix();
+ let isRoom = channel.handle_type == Tp.HandleType.ROOM;
+ let channelName = channel.identifier;
+
+ let message = Polari.Message.new_from_tp_message (tpMessage);
+ let res = message.to_tracker_resource(accountId, channelName, isRoom);
+
+ let nsManager = connection.get_namespace_manager();
+ let sparql = res.print_sparql_update(nsManager, null);
+ connection.update_async(sparql, 0, null, (o, res) => {
+ try {
+ connection.update_finish(res);
+ } catch (e) {
+ log(`Failed to log message: ${e.message}`);
+ }
+ });
+ }
+
+ _onMessageSent(channel, msg) {
+ this._logMessage(msg, channel);
+ }
+
_onMessageReceived(channel, msg) {
+ this._logMessage(msg, channel);
+
let [id] = msg.get_pending_message_id();
let room = this._roomManager.lookupRoomByChannel(channel);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]