[backend] lastnotifications: improve 'next' logic