def _ValidateUploadReply(jsonData): # text is optional # key is optional # text and key cannot both be null # threadID is required threadID = jsonData[Const.Views.UploadReply.JsonRequestKey.THREAD_ID] text = jsonData[Const.Views.UploadReply.JsonRequestKey.REPLY_TEXT] key = jsonData[Const.Views.UploadReply.JsonRequestKey.REPLY_URL] # If the key exists, check if it is valid if (not Utils.StringIsEmpty(key) and not _S3KeyIsValid(key)): return False # if threadID is empty or corrupt, invalid if (not _GravityUUIDIsValid(threadID)): return False # if text and key are both empty, invalid if (Utils.StringIsEmpty(text) and Utils.StringIsEmpty(key)): return False # check max lengths of text if (Utils.StringExceedsMaxLength(text, Const.Database.MaxLengths.Content.REPLY_TEXT)): return False # else return True
def _ValidateAnalyticsFeedback(jsonData): # text is required text = jsonData[Const.Views.AnalyticsFeedback.JsonRequestKey.TEXT] # check length of text if (Utils.StringExceedsMaxLength(text, Const.Database.MaxLengths.Analytics.FEEDBACK)): return False return True
def _ValidateUploadLive(jsonData): # key and arn are required # text is optional text = jsonData[Const.Views.UploadThread.JsonRequestKey.THREAD_TEXT] key = jsonData[Const.Views.UploadThread.JsonRequestKey.THREAD_URL] arn = jsonData[Const.Views.UploadThread.JsonRequestKey.THREAD_ARN] # Check that the key exists and is valid if (not _S3KeyIsValid(key)): return False # Check that the arn exists if (Utils.StringIsEmpty(arn)): return False # If the text, or arn exceed max lengths, invalid if (Utils.StringExceedsMaxLength(text, Const.Database.MaxLengths.Content.THREAD_TEXT) or Utils.StringExceedsMaxLength(arn, Const.Database.MaxLengths.AWS_ARN)): return False #else return True