Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support Mentions #18

Closed
ReagentX opened this issue Jul 16, 2022 · 11 comments
Closed

Support Mentions #18

ReagentX opened this issue Jul 16, 2022 · 11 comments
Assignees
Labels
crate: cli Related to the CLI crate crate: database Related to the database crate html Related to HTML Export new feature Requires creating a new feature table Related to table data

Comments

@ReagentX
Copy link
Owner

iMessage has a feature where you can mention chat participants:

image

There is only one column in the database that seems related to mentions: has_unseen_mention. It is just a boolean column, though, so it contains no data on what or who was mentioned. The binary blob columns also do not seem to have any information out of the ordinary. Thus, I am not sure how to proceed with this feature.

@ReagentX ReagentX added table Related to table data new feature Requires creating a new feature labels Jul 16, 2022
@ReagentX
Copy link
Owner Author

ReagentX commented Jan 9, 2023

The attributedBody data contains no delimiters in the body text:

image

There is an additional field called __kIMMentionConfirmedMention, but it only contains the handle's number/email, not the location of the mention within the message body.

@goldkehlchen
Copy link

Just a quick thought, but cross-referencing the number/email with the user's contacts and then searching for the contact's name in the message seems to be the only way to find the mention in the message - albeit with quite a lot of effort required to make it work.

@ReagentX
Copy link
Owner Author

ReagentX commented Jan 17, 2023

See #62, this software will not target features outside of the iMessage database.

Also, you can type contact names without transforming them into mentions; a string search doesn't have enough context to handle that case.

@tneotia
Copy link

tneotia commented Jan 23, 2023

The attributedBody does contain the range of text that should be annotated with the mention. If parsing the attributedBody, you should see a list of message parts, and this will contain a part for the mention as well with a corrseponding range. For example, if the text is:

Hi ReagentX, here's an example for issue 18!

The attributedBody will have three parts inside it:

1st part: Hi
2nd part: ReagentX
3rd part: , here's an example for issue 18!

And these three will have NSRanges. This also works with multi-part messages.

@ReagentX
Copy link
Owner Author

ReagentX commented Jan 23, 2023

And these three will have NSRanges

Where? I don't see any delimiters in the attributedBody. I'm also not sure how much of the streamtyped data I can parse without reaching into NSUnarchiver, which I am not sure I can even do in Rust.

@tneotia
Copy link

tneotia commented Jan 23, 2023

"attributedBody": [{
            "string": "Heya  every part of this message that you can still see was sent from macOS Ventura Tanay mandatory mention",
            "runs": [{
                "range": [0, 4],
                "attributes": {
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 0
                }
            }, {
                "range": [4, 1],
                "attributes": {
                    "__kIMFileTransferGUIDAttributeName": "624F228F-8EE7-4FBD-9AD8-CA87FEDC0D9F",
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 1
                }
            }, {
                "range": [5, 1],
                "attributes": {
                    "__kIMFileTransferGUIDAttributeName": "29B4410B-10EC-42B4-8AD6-83BF7E94599F",
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 3
                }
            }, {
                "range": [6, 77],
                "attributes": {
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 4
                }
            }, {
                "range": [83, 1],
                "attributes": {
                    "__kIMFileTransferGUIDAttributeName": "C4D638E6-76C0-4BAE-B637-AD9E96F44489",
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 5
                }
            }, {
                "range": [84, 5],
                "attributes": {
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 6,
                    "__kIMMentionConfirmedMention": "<address>"
                }
            }, {
                "range": [89, 18],
                "attributes": {
                    "__kIMBaseWritingDirectionAttributeName": -1,
                    "__kIMMessagePartAttributeName": 6
                }
            }]
        }],

Here is an example of an actual deserialized attributedBody, notice that the second to last part is the mention and has NSRange(84,5)

@tneotia
Copy link

tneotia commented Jan 23, 2023

I'm part of the bluebubbles team (https://github.com/BlueBubblesApp). Our server uses node and one of our users / contributors made a node package to deserialize these with NSKeyedUnarchiver - https://www.npmjs.com/package/node-typedstream

Works great for attributedBody, messageSummaryInfo, and payloadData

@ReagentX
Copy link
Owner Author

Got it, thanks, this is extremely helpful.

ReagentX added a commit that referenced this issue Jun 13, 2024
@ReagentX ReagentX moved this to In Progress in 2.0: California Poppy Jun 13, 2024
@ReagentX ReagentX added crate: database Related to the database crate crate: cli Related to the CLI crate html Related to HTML Export labels Jun 13, 2024
@ReagentX
Copy link
Owner Author

ReagentX commented Jun 13, 2024

Tracking support for this and a custom attributedBody parser in Rust in the feat/cs/attributedBody-parse branch, which will also be required for #273. The existing Python/Node libs were helpful, but not what I wanted, so I ended up writing my own parser.

@ReagentX ReagentX self-assigned this Jun 13, 2024
@ReagentX
Copy link
Owner Author

ReagentX commented Jun 19, 2024

An attributedBody like:

image

Gets parsed as:

image

@ReagentX
Copy link
Owner Author

At long last, we have come full circle:

image

@ReagentX ReagentX moved this from In Progress to Done in 2.0: California Poppy Jul 27, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
KevinPBurke pushed a commit to KevinPBurke/imessage-exporter that referenced this issue Aug 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
crate: cli Related to the CLI crate crate: database Related to the database crate html Related to HTML Export new feature Requires creating a new feature table Related to table data
Projects
No open projects
Development

No branches or pull requests

3 participants