This commit is contained in:
@@ -22,7 +22,7 @@ Remove OwnerId
|
|||||||
- Event object uses it see eventlog above
|
- Event object uses it see eventlog above
|
||||||
- FormCustom uses it much like DataFilter does, could also be renamed to UserId and semantically be better
|
- FormCustom uses it much like DataFilter does, could also be renamed to UserId and semantically be better
|
||||||
- UserOptions (rename to userID)
|
- UserOptions (rename to userID)
|
||||||
- OpsJob (might be removable?)
|
- OpsJob (might be removable, rename it CreatorID? Or, if it's already logged in the event log then maybe no creator ID is required at all.)
|
||||||
|
|
||||||
OwnerID is put on httpcontext in startup.cs, will it still be necessary?
|
OwnerID is put on httpcontext in startup.cs, will it still be necessary?
|
||||||
Clean up owner ID and rules now that it's deprecated
|
Clean up owner ID and rules now that it's deprecated
|
||||||
|
|||||||
@@ -186,14 +186,16 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!badRequest)
|
if (!badRequest)
|
||||||
{
|
{
|
||||||
//check if object exists
|
//check if object exists
|
||||||
// long attachToObjectOwnerId = attachToObject.OwnerId(ct);
|
//Updated code: this used to check if the ownerId was -1 to see if it didn't exist, but since ownerId zapped this seems like the next best way to do it
|
||||||
// if (attachToObjectOwnerId == -1)
|
//Not sure at all what the ownerid check was doing before that verified it's existance, the code is long gone now and I can't be arsed to look it up in the repo history
|
||||||
// {
|
//If the tests pass then it's fine :)
|
||||||
// badRequest = true;
|
if (!BizObjectExistsInDatabase.Exists(attachToObject))
|
||||||
// errorMessage = "Invalid attach object";
|
{
|
||||||
// }
|
badRequest = true;
|
||||||
// else
|
errorMessage = "Invalid attach object";
|
||||||
// {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// User needs modify rights to the object type in question
|
// User needs modify rights to the object type in question
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, attachToObject.ObjectType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, attachToObject.ObjectType))
|
||||||
{
|
{
|
||||||
@@ -202,7 +204,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -222,7 +224,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
foreach (UploadedFileInfo a in uploadFormData.UploadedFiles)
|
foreach (UploadedFileInfo a in uploadFormData.UploadedFiles)
|
||||||
{
|
{
|
||||||
var v = FileUtil.storeFileAttachment(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, UserId, attachToObject, ct);
|
var v = FileUtil.storeFileAttachment(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, attachToObject, ct);
|
||||||
returnList.Add(new NameIdItem()
|
returnList.Add(new NameIdItem()
|
||||||
{
|
{
|
||||||
Name = v.DisplayFileName,
|
Name = v.DisplayFileName,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace AyaNova.Biz
|
|||||||
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
||||||
//Seeder sets user options in advance so no need to create them here in that case
|
//Seeder sets user options in advance so no need to create them here in that case
|
||||||
if (inObj.UserOptions == null)
|
if (inObj.UserOptions == null)
|
||||||
inObj.UserOptions = new UserOptions(UserId);
|
inObj.UserOptions = new UserOptions();
|
||||||
|
|
||||||
|
|
||||||
Validate(inObj, null);
|
Validate(inObj, null);
|
||||||
@@ -103,7 +103,7 @@ namespace AyaNova.Biz
|
|||||||
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
inObj.Tags = TagUtil.NormalizeTags(inObj.Tags);
|
||||||
//Seeder sets user options in advance so no need to create them here in that case
|
//Seeder sets user options in advance so no need to create them here in that case
|
||||||
if (inObj.UserOptions == null)
|
if (inObj.UserOptions == null)
|
||||||
inObj.UserOptions = new UserOptions(UserId);
|
inObj.UserOptions = new UserOptions();
|
||||||
|
|
||||||
Validate(inObj, null);
|
Validate(inObj, null);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ namespace AyaNova.Models
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public uint ConcurrencyToken { get; set; }
|
public uint ConcurrencyToken { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public long OwnerId { get; set; }
|
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
[Required]
|
[Required]
|
||||||
public long AttachToObjectId { get; set; }
|
public long AttachToObjectId { get; set; }
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
LogUpdateMessage(log);
|
LogUpdateMessage(log);
|
||||||
|
|
||||||
exec("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, ownerid bigint not null," +
|
exec("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, " +
|
||||||
"attachtoobjectid bigint not null, attachtoobjecttype integer not null, " +
|
"attachtoobjectid bigint not null, attachtoobjecttype integer not null, " +
|
||||||
"storedfilename text not null, displayfilename text not null, contenttype text, notes text)");
|
"storedfilename text not null, displayfilename text not null, contenttype text, notes text)");
|
||||||
|
|
||||||
|
|||||||
@@ -256,11 +256,10 @@ namespace AyaNova.Util
|
|||||||
/// <param name="tempFilePath"></param>
|
/// <param name="tempFilePath"></param>
|
||||||
/// <param name="contentType"></param>
|
/// <param name="contentType"></param>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="attachToObject"></param>
|
/// <param name="attachToObject"></param>
|
||||||
/// <param name="ct"></param>
|
/// <param name="ct"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static FileAttachment storeFileAttachment(string tempFilePath, string contentType, string fileName, long userId, AyaTypeId attachToObject, AyContext ct)
|
internal static FileAttachment storeFileAttachment(string tempFilePath, string contentType, string fileName, AyaTypeId attachToObject, AyContext ct)
|
||||||
{
|
{
|
||||||
//calculate hash
|
//calculate hash
|
||||||
var hash = FileHash.GetChecksum(tempFilePath);
|
var hash = FileHash.GetChecksum(tempFilePath);
|
||||||
@@ -286,7 +285,6 @@ namespace AyaNova.Util
|
|||||||
//Build AyFileInfo
|
//Build AyFileInfo
|
||||||
FileAttachment fi = new FileAttachment()
|
FileAttachment fi = new FileAttachment()
|
||||||
{
|
{
|
||||||
OwnerId = userId,
|
|
||||||
StoredFileName = hash,
|
StoredFileName = hash,
|
||||||
DisplayFileName = fileName,
|
DisplayFileName = fileName,
|
||||||
Notes = string.Empty,
|
Notes = string.Empty,
|
||||||
|
|||||||
Reference in New Issue
Block a user