Skip to content

Commit

Permalink
#50 Don't filter meta-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Feb 15, 2018
1 parent 234ce1e commit bc47a5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/org/elastic4play/models/ModelDef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,14 @@ class BaseEntity(val model: BaseModelDef, val attributes: JsObject) {
private final def removeProtectedAttributes(attrs: JsObject) = JsObject {
attrs.fields
.map { case (name, value) (name, value, model.attributes.find(_.attributeName == name)) }
.collect { case (name, value, Some(desc)) if !desc.isSensitive name value }
.collect {
case (name, value, Some(desc)) if !desc.isSensitive name value
case (name, value, _) if name.startsWith("_") name value
}
}

def toJson = removeProtectedAttributes(attributes) +
("id" JsString(id)) +
("_type" JsString(model.modelName))
("id" JsString(id))

/* compute auxiliary data */
override def toString = Json.prettyPrint(toJson)
Expand Down
5 changes: 4 additions & 1 deletion app/org/elastic4play/services/AuxSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class AuxSrv @Inject() (
JsObject(
entity.attributes.fields
.map { case (name, value) (name, value, entity.model.attributes.find(_.attributeName == name)) }
.collect { case (name, value, Some(desc)) if !desc.options.contains(AttributeOption.unaudited) name value }) +
.collect {
case (name, value, Some(desc)) if !desc.options.contains(AttributeOption.unaudited) name value
case (name, value, _) if name.startsWith("_") name value
}) +
("id" JsString(entity.id)) +
("_type" JsString(entity.model.modelName))
}
Expand Down

0 comments on commit bc47a5e

Please sign in to comment.