Skip to content

Commit

Permalink
always use accountID as an NSNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
lissine0 authored and tmolitor-stud-tu committed Aug 29, 2024
1 parent 2a0d8b1 commit 96b53d0
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions Monal/Classes/DataLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ -(void) removeBuddy:(NSString*) buddy forAccount:(NSNumber*) accountID
}];
}

-(BOOL) clearBuddies:(NSString*) accountID
-(BOOL) clearBuddies:(NSNumber*) accountID
{
return [self.db boolWriteTransaction:^{
return [self.db executeNonQuery:@"DELETE FROM buddylist WHERE account_id=?;" andArguments:@[accountID]];
Expand Down Expand Up @@ -676,7 +676,7 @@ -(void) setOnlineBuddy:(XMPPPresence*) presenceObj forAccount:(NSNumber*) accoun
}];
}

-(void) setOfflineBuddy:(XMPPPresence*) presenceObj forAccount:(NSString*) accountID
-(void) setOfflineBuddy:(XMPPPresence*) presenceObj forAccount:(NSNumber*) accountID
{
return [self.db voidWriteTransaction:^{
[self.db executeNonQuery:@"DELETE FROM buddy_resources AS R WHERE resource=? AND EXISTS(SELECT * FROM buddylist AS B WHERE B.buddy_id=R.buddy_id AND B.account_id=? AND B.buddy_name=?);" andArguments:@[presenceObj.fromResource ? presenceObj.fromResource : @"", accountID, presenceObj.fromUser]];
Expand All @@ -702,7 +702,7 @@ -(void) setBuddyState:(XMPPPresence*) presenceObj forAccount:(NSNumber*) account
}];
}

-(NSString*) buddyState:(NSString*) buddy forAccount:(NSString*) accountID
-(NSString*) buddyState:(NSString*) buddy forAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
NSString* query = @"SELECT state FROM buddylist WHERE account_id=? AND buddy_name=?;";
Expand Down Expand Up @@ -748,7 +748,7 @@ -(void) deleteContactRequest:(MLContact*) requestor
}];
}

-(void) setBuddyStatus:(XMPPPresence*) presenceObj forAccount:(NSString*) accountID
-(void) setBuddyStatus:(XMPPPresence*) presenceObj forAccount:(NSNumber*) accountID
{
NSString* toPass = @"";
if([presenceObj check:@"status#"])
Expand All @@ -766,20 +766,20 @@ -(void) setBuddyStatus:(XMPPPresence*) presenceObj forAccount:(NSString*) accoun
}];
}

-(NSString*) buddyStatus:(NSString*) buddy forAccount:(NSString*) accountID
-(NSString*) buddyStatus:(NSString*) buddy forAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
NSString* query = @"SELECT status FROM buddylist WHERE account_id=? AND buddy_name=?;";
NSString* iconname = (NSString *)[self.db executeScalar:query andArguments:@[accountID, buddy]];
NSString* iconname = (NSString *)[self.db executeScalar:query andArguments:@[accountID, buddy]];
return iconname;
}];
}

-(NSString *) getRosterVersionForAccount:(NSString*) accountID
-(NSString *) getRosterVersionForAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
NSString* query = @"SELECT rosterVersion FROM account WHERE account_id=?;";
NSArray* params = @[ accountID];
NSArray* params = @[accountID];
NSString * version=(NSString*)[self.db executeScalar:query andArguments:params];
return version;
}];
Expand Down Expand Up @@ -976,9 +976,9 @@ -(void) removeParticipant:(NSDictionary*) participant fromMuc:(NSString*) room f
}];
}

-(void) addMember:(NSDictionary*) member toMuc:(NSString*) room forAccountID:(NSString*) accountID
-(void) addMember:(NSDictionary*) member toMuc:(NSString*) room forAccountID:(NSNumber*) accountID
{
if(!member || !member[@"jid"] || !room || !accountID)
if(!member || !member[@"jid"] || !room || accountID == nil)
return;

[self.db voidWriteTransaction:^{
Expand Down Expand Up @@ -1067,14 +1067,14 @@ -(void) addMucFavorite:(NSString*) room forAccountID:(NSNumber*) accountID andMu
}];
}

-(NSString*) lastStanzaIdForMuc:(NSString* _Nonnull) room andAccount:(NSString* _Nonnull) accountID
-(NSString*) lastStanzaIdForMuc:(NSString* _Nonnull) room andAccount:(NSNumber* _Nonnull) accountID
{
return [self.db idReadTransaction:^{
return [self.db executeScalar:@"SELECT lastMucStanzaId FROM buddylist WHERE muc=1 AND account_id=? AND buddy_name=?;" andArguments:@[accountID, room]];
}];
}

-(void) setLastStanzaId:(NSString*) lastStanzaId forMuc:(NSString* _Nonnull) room andAccount:(NSString* _Nonnull) accountID
-(void) setLastStanzaId:(NSString*) lastStanzaId forMuc:(NSString* _Nonnull) room andAccount:(NSNumber* _Nonnull) accountID
{
[self.db voidWriteTransaction:^{
if(lastStanzaId && [lastStanzaId length])
Expand Down Expand Up @@ -1638,10 +1638,10 @@ -(BOOL) checkLMCEligible:(NSNumber*) historyID encrypted:(BOOL) encrypted histor
}

//message history
-(NSNumber*) lastMessageHistoryIdForContact:(NSString*) buddy forAccount:(NSString*) accountID
-(NSNumber*) lastMessageHistoryIdForContact:(NSString*) buddy forAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
return [self.db executeScalar:@"SELECT message_history_id FROM message_history WHERE account_id=? AND buddy_name=? ORDER BY message_history_id DESC LIMIT 1" andArguments:@[ accountID, buddy]];
return [self.db executeScalar:@"SELECT message_history_id FROM message_history WHERE account_id=? AND buddy_name=? ORDER BY message_history_id DESC LIMIT 1" andArguments:@[accountID, buddy]];
}];
}

Expand Down Expand Up @@ -1679,9 +1679,9 @@ -(NSNumber*) lastMessageHistoryIdForContact:(NSString*) buddy forAccount:(NSStri
}];
}

-(MLMessage*) lastMessageForContact:(NSString*) contact forAccount:(NSString*) accountID
-(MLMessage*) lastMessageForContact:(NSString*) contact forAccount:(NSNumber*) accountID
{
if(!accountID || !contact)
if(accountID == nil || !contact)
return nil;

return [self.db idReadTransaction:^{
Expand All @@ -1705,9 +1705,9 @@ -(MLMessage*) lastMessageForContact:(NSString*) contact forAccount:(NSString*) a
}];
}

-(NSArray<MLMessage*>*) markMessagesAsReadForBuddy:(NSString*) buddy andAccount:(NSString*) accountID tillStanzaId:(NSString*) stanzaid wasOutgoing:(BOOL) outgoing
-(NSArray<MLMessage*>*) markMessagesAsReadForBuddy:(NSString*) buddy andAccount:(NSNumber*) accountID tillStanzaId:(NSString*) stanzaid wasOutgoing:(BOOL) outgoing
{
if(!buddy || !accountID)
if(!buddy || accountID == nil)
{
DDLogError(@"No buddy or accountID specified!");
return @[];
Expand Down Expand Up @@ -1833,14 +1833,14 @@ -(NSNumber*) countUnreadMessages
}];
}

-(NSString*) lastStanzaIdForAccount:(NSString*) accountID
-(NSString*) lastStanzaIdForAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
return [self.db executeScalar:@"SELECT lastStanzaId FROM account WHERE account_id=?;" andArguments:@[accountID]];
}];
}

-(void) setLastStanzaId:(NSString*) lastStanzaId forAccount:(NSString*) accountID
-(void) setLastStanzaId:(NSString*) lastStanzaId forAccount:(NSNumber*) accountID
{
[self.db voidWriteTransaction:^{
[self.db executeNonQuery:@"UPDATE account SET lastStanzaId=? WHERE account_id=?;" andArguments:@[lastStanzaId, accountID]];
Expand Down Expand Up @@ -1869,7 +1869,7 @@ -(void) setLastStanzaId:(NSString*) lastStanzaId forAccount:(NSString*) accountI
}];
}

-(void) removeActiveBuddy:(NSString*) buddyname forAccount:(NSString*) accountID
-(void) removeActiveBuddy:(NSString*) buddyname forAccount:(NSNumber*) accountID
{
[self.db voidWriteTransaction:^{
//mark all messages as read
Expand Down Expand Up @@ -1903,7 +1903,7 @@ -(void) addActiveBuddies:(NSString*) buddyname forAccount:(NSNumber*) accountID
}


-(BOOL) isActiveBuddy:(NSString*) buddyname forAccount:(NSString*) accountID
-(BOOL) isActiveBuddy:(NSString*) buddyname forAccount:(NSNumber*) accountID
{
return [self.db boolReadTransaction:^{
NSString* query = @"SELECT COUNT(buddy_name) FROM activechats WHERE account_id=? AND buddy_name=?;";
Expand Down Expand Up @@ -1982,7 +1982,7 @@ -(void) updateUsedPushServer:(NSString*) pushServer forAccount:(NSNumber*) accou
}];
}

-(void) deleteDelayedMessageStanzasForAccount:(NSString*) accountID
-(void) deleteDelayedMessageStanzasForAccount:(NSNumber*) accountID
{
[self.db voidWriteTransaction:^{
[self.db executeNonQuery:@"DELETE FROM delayed_message_stanzas WHERE account_id=?;" andArguments:@[accountID]];
Expand Down Expand Up @@ -2112,9 +2112,9 @@ -(void) unMuteContact:(MLContact*) contact
}];
}

-(BOOL) isMutedJid:(NSString*) jid onAccount:(NSString*) accountID
-(BOOL) isMutedJid:(NSString*) jid onAccount:(NSNumber*) accountID
{
if(!jid || !accountID)
if(!jid || accountID == nil)
{
unreachable();
return NO;
Expand All @@ -2125,9 +2125,9 @@ -(BOOL) isMutedJid:(NSString*) jid onAccount:(NSString*) accountID
}];
}

-(void) setMucAlertOnMentionOnly:(NSString*) jid onAccount:(NSString*) accountID
-(void) setMucAlertOnMentionOnly:(NSString*) jid onAccount:(NSNumber*) accountID
{
if(!jid || !accountID)
if(!jid || accountID == nil)
{
unreachable();
return;
Expand All @@ -2137,9 +2137,9 @@ -(void) setMucAlertOnMentionOnly:(NSString*) jid onAccount:(NSString*) accountID
}];
}

-(void) setMucAlertOnAll:(NSString*) jid onAccount:(NSString*) accountID
-(void) setMucAlertOnAll:(NSString*) jid onAccount:(NSNumber*) accountID
{
if(!jid || !accountID)
if(!jid || accountID == nil)
{
unreachable();
return;
Expand All @@ -2149,9 +2149,9 @@ -(void) setMucAlertOnAll:(NSString*) jid onAccount:(NSString*) accountID
}];
}

-(BOOL) isMucAlertOnMentionOnly:(NSString*) jid onAccount:(NSString*) accountID
-(BOOL) isMucAlertOnMentionOnly:(NSString*) jid onAccount:(NSNumber*) accountID
{
if(!jid || !accountID)
if(!jid || accountID == nil)
{
unreachable();
return NO;
Expand Down Expand Up @@ -2245,7 +2245,7 @@ -(uint8_t) isBlockedContact:(MLContact*) contact
}] intValue];
}

-(NSArray<NSDictionary<NSString*, NSString*>*>*) blockedJidsForAccount:(NSString*) accountID
-(NSArray<NSDictionary<NSString*, NSString*>*>*) blockedJidsForAccount:(NSNumber*) accountID
{
return [self.db idReadTransaction:^{
NSArray* blockedJidsFromDB = [self.db executeReader:@"SELECT * FROM blocklistCache WHERE account_id=?" andArguments:@[accountID]];
Expand All @@ -2267,9 +2267,9 @@ -(uint8_t) isBlockedContact:(MLContact*) contact
}];
}

-(BOOL) isPinnedChat:(NSString*) accountID andBuddyJid:(NSString*) buddyJid
-(BOOL) isPinnedChat:(NSNumber*) accountID andBuddyJid:(NSString*) buddyJid
{
if(!accountID || !buddyJid)
if(accountID == nil || !buddyJid)
return NO;
return [self.db boolReadTransaction:^{
NSNumber* pinnedNum = [self.db executeScalar:@"SELECT pinned FROM activechats WHERE account_id=? AND buddy_name=?;" andArguments:@[accountID, buddyJid]];
Expand All @@ -2280,17 +2280,17 @@ -(BOOL) isPinnedChat:(NSString*) accountID andBuddyJid:(NSString*) buddyJid
}];
}

-(void) pinChat:(NSString*) accountID andBuddyJid:(NSString*) buddyJid
-(void) pinChat:(NSNumber*) accountID andBuddyJid:(NSString*) buddyJid
{
if(!accountID || !buddyJid)
if(accountID == nil || !buddyJid)
return;
[self.db voidWriteTransaction:^{
[self.db executeNonQuery:@"UPDATE activechats SET pinned=1 WHERE account_id=? AND buddy_name=?" andArguments:@[accountID, buddyJid]];
}];
}
-(void) unPinChat:(NSString*) accountID andBuddyJid:(NSString*) buddyJid
-(void) unPinChat:(NSNumber*) accountID andBuddyJid:(NSString*) buddyJid
{
if(!accountID || !buddyJid)
if(accountID == nil || !buddyJid)
return;
[self.db voidWriteTransaction:^{
[self.db executeNonQuery:@"UPDATE activechats SET pinned=0 WHERE account_id=? AND buddy_name=?" andArguments:@[accountID, buddyJid]];
Expand Down Expand Up @@ -2334,9 +2334,9 @@ -(void) removeImageCacheTables
}];
}

-(NSMutableArray*) allAttachmentsFromContact:(NSString*) contact forAccount:(NSString*) accountID
-(NSMutableArray*) allAttachmentsFromContact:(NSString*) contact forAccount:(NSNumber*) accountID
{
if(!accountID ||! contact)
if(accountID == nil ||! contact)
return nil;

return [self.db idReadTransaction:^{
Expand Down

0 comments on commit 96b53d0

Please sign in to comment.