Skip to content

Commit

Permalink
#205 remove duplicate potential artifact tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed May 17, 2017
1 parent 29c2eab commit c168a97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion thehive-backend/app/models/Artifact.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import javax.inject.{ Inject, Provider, Singleton }
import scala.concurrent.{ ExecutionContext, Future }
import scala.language.postfixOps
import akka.stream.Materializer
import play.api.libs.json.{ JsNull, JsObject, JsString, JsValue }
import play.api.libs.json.{ JsNull, JsObject, JsString, JsValue, JsArray }
import play.api.libs.json.JsLookupResult.jsLookupResultToJsLookup
import play.api.libs.json.JsValue.jsValueToJsLookup
import play.api.libs.json.Json
Expand Down Expand Up @@ -47,6 +47,11 @@ class ArtifactModel @Inject() (
implicit val ec: ExecutionContext) extends ChildModelDef[ArtifactModel, Artifact, CaseModel, Case](caseModel, "case_artifact") with ArtifactAttributes with AuditedModel {
override val removeAttribute: JsObject = Json.obj("status" ArtifactStatus.Deleted)

override def apply(attributes: JsObject) = {
val tags = (attributes \ "tags").asOpt[Seq[JsString]].getOrElse(Nil).distinct
new Artifact(this, attributes + ("tags" JsArray(tags)))
}

// this method modify request in order to hash artifact and manager file upload
override def creationHook(parent: Option[BaseEntity], attrs: JsObject): Future[JsObject] = {
val keys = attrs.keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h4>List of observables ({{artifacts.total || 0}} of {{artifactStats.count}})</h
</td>
<td class="wrap clickable" ng-click="openArtifact(artifact)">{{(artifact.data | fang) || (artifact.attachment.name | fang)}}</td>
<td>
<span ng-repeat="l in artifact.tags">
<span ng-repeat="l in artifact.tags track by $index">
<span class="label label-primary mr-xxxs pointer" ng-click="addFilterValue('tags', l)">
<i class="glyphicon glyphicon-tag"></i> <span ng-bind="l"></span>
</span>
Expand Down

0 comments on commit c168a97

Please sign in to comment.