Skip to content

Commit

Permalink
#303 Add owner attribute to log entities
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om authored and nadouani committed Oct 19, 2017
1 parent cd2ec56 commit 6295a93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions thehive-backend/app/models/Log.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ trait LogAttributes { _: AttributeDef ⇒
// - contentType (string): the mimetype of the file (send by client)
val attachment = optionalAttribute("attachment", F.attachmentFmt, "Attached file", O.readonly)
val status = attribute("status", F.enumFmt(LogStatus), "Status of the log", LogStatus.Ok)
val owner = attribute("owner", F.stringFmt, "User who owns the log")
}

@Singleton
Expand Down
6 changes: 6 additions & 0 deletions thehive-backend/app/models/Migration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ class Migration(
val customFields = (caze \ "customFields").asOpt[JsObject].getOrElse(JsObject(Nil))
caze + ("metrics" metrics) + ("customFields" customFields)
})
case DatabaseState(10)
Seq(
mapEntity("case_task_log") { log
val owner = (log \ "createdBy").asOpt[JsString].getOrElse(JsString("init"))
log + ("owner" owner)
})
}

private val requestCounter = new java.util.concurrent.atomic.AtomicInteger(0)
Expand Down
5 changes: 3 additions & 2 deletions thehive-backend/app/services/LogSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class LogSrv @Inject() (
getSrv[TaskModel, Task](taskModel, taskId)
.flatMap { task create(task, fields) }

def create(task: Task, fields: Fields)(implicit authContext: AuthContext): Future[Log] =
createSrv[LogModel, Log, Task](logModel, task, fields)
def create(task: Task, fields: Fields)(implicit authContext: AuthContext): Future[Log] = {
createSrv[LogModel, Log, Task](logModel, task, fields.addIfAbsent("owner", authContext.userId))
}

def get(id: String): Future[Log] =
getSrv[LogModel, Log](logModel, id)
Expand Down

0 comments on commit 6295a93

Please sign in to comment.