Code Monkey home page Code Monkey logo

Comments (11)

davidvella avatar davidvella commented on July 30, 2024 3

I got it working. It looks like Whatsapp have changed the schema of the db a lot. I had to recreate the view
and insert it into the android msgstore.db manually.

I found the original view here

This is what I wrote:

CREATE view legacy_available_messages_view
AS
  SELECT messages.*,
         chat._id          AS chat_row_id,
         expire_timestamp,
         jid.raw_string    AS key_remote_jid,
         jid2.raw_string   AS remote_resource,
         messages.text_data AS data,
         messages.from_me  AS key_from_me
  FROM   message AS messages
         JOIN chat
           ON chat._id = messages.chat_row_id
         JOIN jid AS jid
           ON chat.jid_row_id = jid._id
         LEFT JOIN jid AS jid2
                ON messages.sender_jid_row_id = jid2._id
         LEFT JOIN deleted_chat_job AS job
                ON job.chat_row_id = chat._id
         LEFT JOIN message_ephemeral AS message_ephemeral
                ON messages._id = message_ephemeral.message_row_id
  WHERE  Ifnull(NOT( ( Ifnull(messages.starred, 0) = 0
                       AND messages._id <= Ifnull(job.deleted_message_row_id, 1)
                     )
                      OR ( Ifnull(messages.starred, 0) = 1
                           AND messages._id <=
                               Ifnull(job.deleted_starred_message_row_id,
                               1) )
                      OR ( ( job.deleted_message_categories IS NOT NULL )
                           AND ( ( Ifnull(messages.starred, 0) = 0
                                   AND messages._id <=
                           Ifnull(job.deleted_categories_message_row_id,
                           1) )
                                  OR ( Ifnull(messages.starred, 0) = 1
                                       AND messages._id <=
                     Ifnull(job.deleted_categories_starred_message_row_id,
                     1) ) ) ) ), 0) 

This is me just hacking to get something to work. Some values are missing such as messages.media_wa_type from orig db (not sure what this should be).

Someone will need to change watoi code to either create the view if missing or change this query:

- (void) importMessages {
    NSString *query = @"SELECT * FROM legacy_available_messages_view where"
                       " key_remote_jid == '%@'"
                       " AND status != 6"  // Some system messages
                       " ORDER BY timestamp";

from watoi.

venusjivani avatar venusjivani commented on July 30, 2024

whatsapp-viewer also failed due to this new table, here is issue detail.

from watoi.

officialasit avatar officialasit commented on July 30, 2024

Hey @davidvella , I tried the sql commands on my database but now I'm getting this error:

Loaded 466 chat(s)
no such column: messages.textdata
zsh: abort      watoi/build/Release/watoi msgstore.db ./ChatStorage.sqlite 

from watoi.

officialasit avatar officialasit commented on July 30, 2024

Fixed by replacing messages.textdata AS text, with messages.text_data AS text, in the SQL Query.

from watoi.

davidvella avatar davidvella commented on July 30, 2024

Fixed by replacing messages.textdata AS text, with messages.text_data AS text, in the SQL Query.

Thanks @officialasit. I originally made changes in both the sql and the code. Thanks for spotting the typo. Will update original comment

from watoi.

officialasit avatar officialasit commented on July 30, 2024

@davidvella I have restored the messages, but all the messages seem to be blank. Like its showing the conversations, but no text in them. Any solutions?

from watoi.

davidvella avatar davidvella commented on July 30, 2024

@davidvella I have restored the messages, but all the messages seem to be blank. Like its showing the conversations, but no text in them. Any solutions?

It looks like my mistake again.

If you look at:

NSString *text = [amsg objectForKey:@"data"]; // or null

The text column should be data in the view.

I did hack the solution. Something else I must have changed.

Updated the view again

from watoi.

officialasit avatar officialasit commented on July 30, 2024

@davidvella Thanks a lot. It worked this time. :)

from watoi.

venusjivani avatar venusjivani commented on July 30, 2024

@davidvella many thanks, manages to successfully restored using the hack you suggested 🙏

from watoi.

shikharkunal99 avatar shikharkunal99 commented on July 30, 2024

@davidvella can you please tell the steps to insert the legacy_available_messages_view into msgstore.db?

from watoi.

shikharkunal99 avatar shikharkunal99 commented on July 30, 2024

nvm. i used https://sqlitebrowser.org/dl/ to open the db file and update the view

from watoi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.