Skip to content

Commit 071f867

Browse files
Don't handle messages older than our autodelete timeout
This should fix oss' crash in the alpha.
1 parent f2012d8 commit 071f867

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Monal/Classes/MLMessageProcessor.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,28 @@ +(MLMessage* _Nullable) processMessage:(XMPPMessage*) messageNode andOuterMessag
117117
return nil;
118118
}
119119

120-
if([messageNode check:@"/<type=headline>/{http://jabber.org/protocol/pubsub#event}event"])
120+
if([messageNode check:@"/<type=headline>/{http://jabber.org/protocol/pubsub#event}event"] && !isMLhistory)
121121
{
122122
[account.pubsub handleHeadlineMessage:messageNode];
123123
return nil;
124124
}
125125

126+
//ignore messages older than our autodelete time
127+
//(history backscrolling ones AND normal ones, both would otherwise disappear again immediately afterwards)
128+
//do this before handling the message stanza: only non-MLhistory pubsub messages and error-type stanzas should be processed
129+
//regardless of their age (but pubsub messages only if they aren't MLhistory ones)
130+
NSInteger autodeleteInterval = [[HelperTools defaultsDB] integerForKey:@"AutodeleteInterval"];
131+
if(autodeleteInterval > 0)
132+
{
133+
NSDate* pastDate = [NSDate dateWithTimeIntervalSinceNow:-autodeleteInterval];
134+
NSDate* messageTimestamp = [messageNode findFirst:@"{urn:xmpp:delay}delay@stamp|datetime"];
135+
if(messageTimestamp != nil && [messageTimestamp compare:pastDate] == NSOrderedAscending)
136+
{
137+
DDLogInfo(@"Ignoring incoming message being too old (probably an MLhistory one)...");
138+
return nil;
139+
}
140+
}
141+
126142
//ignore messages from our own device, see this github issue: https://github.com/monal-im/Monal/issues/941
127143
if(![messageNode check:@"/<type=groupchat>"] && !isMLhistory && [messageNode.from isEqualToString:account.connectionProperties.identity.fullJid] && [messageNode.toUser isEqualToString:account.connectionProperties.identity.jid])
128144
return nil;

0 commit comments

Comments
 (0)