in src/main/scala/middleware/FieldPermissions.scala [41:55]
override def afterField(queryVal: Unit, fieldVal: Unit, value: Any, mctx: MiddlewareQueryContext[GQLQueryContext, _, _], ctx: Context[GQLQueryContext, _]): Option[Any] = {
if(ctx.ctx.userTier < InternalTier && ctx.field.name=="channels") {
//if we are _not_ in Internal tier, only show information about Open channel
try {
val channelsData = value.asInstanceOf[Seq[com.gu.contentapi.porter.model.ContentChannel]]
Some(channelsData.filter(_.channelId=="open"))
} catch {
case err:Throwable=>
logger.error(s"Could not apply restrictions to channels: ${err.getMessage}", err)
None
}
} else {
Some(value)
}
}