Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix check for rows affected

Acho Arnold35b2e84a1bde
diff --git a/api/pkg/repositories/gorm_billing_usage_repository.go b/api/pkg/repositories/gorm_billing_usage_repository.go
index a2a68c77..445cd63e 100644
--- a/api/pkg/repositories/gorm_billing_usage_repository.go
+++ b/api/pkg/repositories/gorm_billing_usage_repository.go
@@ -47,7 +47,7 @@ func (repository *gormBillingUsageRepository) RegisterSentMessage(ctx context.Co
Where("user_id = ?", userID).
UpdateColumn("sent_messages", gorm.Expr("sent_messages + ?", 1))
- if result.RowsAffected == 0 {
+ if result.Error == nil && result.RowsAffected == 0 {
return tx.Create(repository.createBillingUsage(userID, 1, 0)).Error
}
return result.Error
@@ -68,7 +68,7 @@ func (repository *gormBillingUsageRepository) RegisterReceivedMessage(ctx contex
Where("user_id = ?", userID).
UpdateColumn("sent_messages", gorm.Expr("received_messages + ?", 1))
- if result.RowsAffected == 0 {
+ if result.Error == nil && result.RowsAffected == 0 {
return tx.Create(repository.createBillingUsage(userID, 0, 1)).Error
}
return result.Error