diff --git a/.settings b/.settings deleted file mode 100644 index 0dc79c2..0000000 --- a/.settings +++ /dev/null @@ -1,15 +0,0 @@ -{ - "disableColors": false, - "groupColors": true, - "conversationsToLoad": 15, - "preventMessageFlicker": false, - "desktopNotifications": false, - "showTimestamps": true, - "useCustomNicknames": true, - "timestampLocale": "en-US", - "timestampOptions": {}, - "twoFactorAuth": false, - "headlessLogin": true, - "noSandbox": false, - "logonTimeout": 86400000 -} diff --git a/lib/listeners.js b/lib/listeners.js index c18fc58..7b344a8 100644 --- a/lib/listeners.js +++ b/lib/listeners.js @@ -1,6 +1,7 @@ const { refreshConsole } = require('./util'); const heading = require('./heading'); const search = require('./search'); +const Settings = require('./settings'); const messageLimit = 75; @@ -33,6 +34,10 @@ class Listeners { thread.snippet = `${ thread.snippet.substr(0, messageLimit) }...`; } + if (Settings.properties.showSenderInMenu && thread.sender) { + line += `[${thread.sender.green}] : `; + } + if (thread.snippet !== '') line += `${thread.snippet} `; diff --git a/lib/messenger.js b/lib/messenger.js index ddf947b..56d8e3f 100644 --- a/lib/messenger.js +++ b/lib/messenger.js @@ -416,13 +416,25 @@ class Messenger { } } + let sender = thread.last_message.nodes[0].message_sender.messaging_actor.id; + if (sender === this.userId) { + sender = "Me"; + } else if (isGroup) { + sender = thread.all_participants.nodes.find( + (n) => n.messaging_actor.id === sender + ).messaging_actor.name; + } else { + sender = ""; + } + return { name, isGroup, 'snippet': thread.last_message.nodes[0].snippet, 'attachments': thread.last_message.nodes[0].blob_attachements, 'thread_fbid': id, - 'timestamp': thread.last_message.nodes[0].timestamp_precise + 'timestamp': thread.last_message.nodes[0].timestamp_precise, + 'sender': sender, }; }); } diff --git a/lib/settings.js b/lib/settings.js index ec0458a..7b0ba90 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -15,6 +15,7 @@ class Settings { conversationsToLoad: 15, preventMessageFlicker: false, desktopNotifications: false, + showSenderInMenu: false, showTimestamps: false, useCustomNicknames: true, timestampLocale: "en-US",