Fill with restrictions

Hello!
I process data from sensors that not always provide data in correct intervals (communication problem). I know, gap longer than X second is not a communication problem but something else important.
So I want to fill(previous) or fill(linear) only if gap is lower than X seconds. Is it possible in InfluxDB query?