Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

senderJID null check needed #31

Open
CopyCat73 opened this issue Nov 17, 2020 · 3 comments
Open

senderJID null check needed #31

CopyCat73 opened this issue Nov 17, 2020 · 3 comments

Comments

@CopyCat73
Copy link

CopyCat73 commented Nov 17, 2020

Converting my android database I get this error:

2020-11-17 16:26:15.904 watoi[7944:253518] missing sender
2020-11-17 16:26:15.904 watoi[7944:253518] -[NSNull componentsSeparatedByString:]: unrecognized selector sent to instance 0x7fff80047290
2020-11-17 16:26:15.904 watoi[7944:253518] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull componentsSeparatedByString:]: unrecognized selector sent to instance 0x7fff80047290'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff204976af __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff201cf3c9 objc_exception_throw + 48
2 CoreFoundation 0x00007fff20519c85 -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x00007fff203ff06d forwarding + 1467
4 CoreFoundation 0x00007fff203fea28 _CF_forwarding_prep_0 + 120
5 watoi 0x0000000105729ac2 -[Importer addMissingMember:toChat:asAdmin:] + 504
6 watoi 0x000000010572b54e -[Importer importMessages] + 1794
7 watoi 0x00000001057289e7 main + 343
8 libdyld.dylib 0x00007fff20340631 start + 1
9 ??? 0x0000000000000004 0x0 + 4
)

Apparently when a member is nil, the code still attempts to add the missing member to the group chat:

            if (isGroup) {
                NSString *senderJID = [amsg objectForKey:@"remote_resource"];
                NSManagedObject *member = [members objectForKey:senderJID];
                if (member == nil) {
                    NSLog(@"\tmissing sender %@", senderJID);
                    member = [self addMissingMember:senderJID toChat:chatJID asAdmin:@NO];
                }

However in my case the missing sender is null, which results in the crash after the log line. I fixed it as follows:

            if (isGroup) {
                NSString *senderJID = [amsg objectForKey:@"remote_resource"];
                NSManagedObject *member = [members objectForKey:senderJID];
                if (member == nil) {
                  if ([senderJID isEqual:[NSNull null]]) {
                      NSLog(@"\tcan't add missing sender %@", senderJID);
                    }
                    else {
                      NSLog(@"\tadding missing sender %@", senderJID);
                      member = [self addMissingMember:senderJID toChat:chatJID asAdmin:@NO];
                    }

                }
@CopyCat73 CopyCat73 changed the title senderJIDmin group is null senderJID null check needed Nov 17, 2020
@residentsummer
Copy link
Owner

Hi, @CopyCat73 !

I'd like to take a look at the new structure of msgstore.db to figure out why remote_resource field is empty. Is it acceptable to ask you to send me an obfuscated copy of your file? If you're OK with that, please remove all sensitive data (see instructions below) and send it to (my github nickname)@gmail.com.

To mask all the text you could use the following commands (media type 0 is for text):

cp msgstore.db msgstore_obfuscated.db
sqlite3 msgstore_obfuscated.db 'update messages set data = "secret" where media_wa_type == 0'
sqlite3 msgstore_obfuscated.db 'update messages set media_caption = "secret" where media_caption != ""'

To check that text is indeed removed:

sqlite3 -header -column msgstore_obfuscated.db 'select * from messages where media_wa_type == 0 limit 10' |less -FRS

@bruno-motacardoso
Copy link

Hello,

I had the same problem. But fixing the script with your code/fix worked fine, thanks @CopyCat73.

Maybe it should be merged with the code @residentsummer ?

@sobhanbera
Copy link

Thanks @CopyCat73! After following yours and other issues fixes, I got it working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants