in app/logic/AuditTrail.scala [122:160]
def auditLogFromAttrs(
attrs: Map[String, AttributeValue]
): Either[(String, Map[String, AttributeValue]), AuditLog] = {
for {
account <- stringValue(attrs, accountPartitionKeyName).toRight(
"Could not extract account" -> attrs
)
username <- stringValue(attrs, userNameAttrName).toRight(
"Could not extract username" -> attrs
)
dateTime <- longValue(attrs, timestampSortKeyName)
.map(epochMilli => Instant.ofEpochMilli(epochMilli))
.toRight("Could not extract dateTime" -> attrs)
duration <- longValue(attrs, durationAttrName)
.map(Duration.ofSeconds)
.toRight("Could not extract duration" -> attrs)
accessLevel <- stringValue(attrs, accessLevelAttrName).toRight(
"Could not extract accessLevel" -> attrs
)
accessType <- stringValue(attrs, accessTypeAttrName)
.flatMap(JanusAccessType.fromString)
.toRight("Could not extract accessType" -> attrs)
external <- longValue(attrs, isExternalAttrName)
.flatMap {
case 0 => Some(false)
case 1 => Some(true)
case _ => None
}
.toRight("Could not extract external" -> attrs)
} yield AuditLog(
account,
username,
dateTime,
duration,
accessLevel,
accessType,
external
)
}