added foolproofing

This commit is contained in:
Nicolas Constant 2020-07-06 00:55:56 -04:00
parent cdfb045c90
commit d846756a7f
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 7 additions and 1 deletions

View File

@ -22,13 +22,15 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
public async Task CreateTwitterUserAsync(string acct, long lastTweetPostedId) public async Task CreateTwitterUserAsync(string acct, long lastTweetPostedId)
{ {
acct = acct.ToLowerInvariant();
using (var dbConnection = Connection) using (var dbConnection = Connection)
{ {
dbConnection.Open(); dbConnection.Open();
await dbConnection.ExecuteAsync( await dbConnection.ExecuteAsync(
$"INSERT INTO {_settings.TwitterUserTableName} (acct,lastTweetPostedId,lastTweetSynchronizedForAllFollowersId) VALUES(@acct,@lastTweetPostedId,@lastTweetSynchronizedForAllFollowersId)", $"INSERT INTO {_settings.TwitterUserTableName} (acct,lastTweetPostedId,lastTweetSynchronizedForAllFollowersId) VALUES(@acct,@lastTweetPostedId,@lastTweetSynchronizedForAllFollowersId)",
new { acct = acct, lastTweetPostedId = lastTweetPostedId, lastTweetSynchronizedForAllFollowersId = lastTweetPostedId }); new { acct, lastTweetPostedId, lastTweetSynchronizedForAllFollowersId = lastTweetPostedId });
} }
} }
@ -36,6 +38,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
{ {
var query = $"SELECT * FROM {_settings.TwitterUserTableName} WHERE acct = @acct"; var query = $"SELECT * FROM {_settings.TwitterUserTableName} WHERE acct = @acct";
acct = acct.ToLowerInvariant();
using (var dbConnection = Connection) using (var dbConnection = Connection)
{ {
dbConnection.Open(); dbConnection.Open();
@ -78,6 +82,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
{ {
if (acct == default) throw new ArgumentException("acct"); if (acct == default) throw new ArgumentException("acct");
acct = acct.ToLowerInvariant();
var query = $"DELETE FROM {_settings.TwitterUserTableName} WHERE acct = @acct"; var query = $"DELETE FROM {_settings.TwitterUserTableName} WHERE acct = @acct";
using (var dbConnection = Connection) using (var dbConnection = Connection)