Здравствуйте.
Столкнулся с проблемой, при запуске сканера для подготовки кода в Sequrity Rewiev, получаю ишью Query: Bulkify Apex Methods Using Collections In Methods:
Object: message
in file: classes/Sender.cls
L 4: public static void sendMessage(Outbound_Message__c message, Sender_Profile_Source__c source) {
Object: message
in file: classes/Sender.cls
L 29: lMessages.add(message);
Object: lmessages
in file: classes/Sender.cls
L 30: update lMessages;
Сам код :
public static void sendMessage(Outbound_Message__c message, Sender_Profile_Source__c source) {
if (FeatureManagement.checkPermission('Sending_Messages')) {
if (([SELECT ResultCode__c FROM Outbound_Message__c WHERE Id = :message.Id LIMIT 1].ResultCode__c != 1005)) {
final String API_Endpoint = 'https://sms/send';
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(API_Endpoint);
AuthData auth = setAuthorization(source, 1);
if (auth.messagesToSendCount > 0) {
request.setHeader('Authorization', auth.authorization);
request.setHeader('Content-Type', 'application/json');
request.setMethod('POST');
request.setBody(getJSONStringToSend(message, auth));
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
message.MessageId__c = (String) responseMap.get('messageId');
message.ResultCode__c = (Integer) responseMap.get('resultCode');
if (Schema.sObjectType.Outbound_Message__c.fields.MessageId__c.isUpdateable() && Schema.sObjectType.Outbound_Message__c.fields.ResultCode__c.isUpdateable()) {
/*============================================================*/
**update message;**
}
Messaging_Account__c account = [SELECT Messages_Sent__c FROM Messaging_Account__c WHERE Id = :auth.accountId];
++account.Messages_Sent__c;
update account;
} else {
System.debug('Something wrong ' + response.getBody());
}
} else {
throw new MessagesLimitException();
}
}
}
}
Я пробовал создавать лист, добавлять в него записи создаваемые и апдейтить его-не выходит. Подскажите что я делаю не так.
Спасибо