message: fix(api): Add ignore update endpoint implementation to fallback file
diff: # This file duplicates the implementation of ot2serverlib
  import os
  +import json
  import asyncio
  import logging
  from time import sleep
  @@ -7,6 +8,8 @@ from aiohttp import web
  from threading import Thread
  log = logging.getLogger(__name__)
  +PATH = os.path.abspath(os.path.dirname(__file__))
  +filepath = os.path.join(PATH, 'ignore.json')
  async def _install(filename, loop):
  @@ -62,6 +65,73 @@ async def install_smoothie_firmware(data, loop):
  return {'message': msg, 'filename': filename}
  +def _set_ignored_version(version):
  + """
  + Private helper function that writes the most updated
  + API version that was ignored by a user in the app
  + :param version: Most recent ignored API update
  + """
  + data = {'version': version}
  + with open(filepath, 'w') as data_file:
  + json.dump(data, data_file)
  +
  +
  +def _get_ignored_version():
  + """
  + :return: Most recently ignored API version
  + """
  + if os.path.exists(filepath):
  + with open(filepath) as data_file:
  + data = json.load(data_file)
  + version = data.get('version')
  + else:
  + version = None
  + return version
  +
  +
  +async def get_ignore_version(request):
  + """
  + This handler returns a GET request of form application/json.
  +
  + The return body will be formatted as:
  + {"version": version_ignored}
  +
  + If no version has been previously ignored, the value will be null
  + """
  + ignored_version = _get_ignored_version()
  + res = {'version': ignored_version}
  + return web.json_response(res)
  +
  +
  +async def set_ignore_version(request):
  + """
  + This handler expects a POST request of form application/json.
  +
  + The request body should be formatted as:
  + {"version": version_ignored}
  +
  + The POST will 400 in the following scenarios:
  + 1. Sending an empty dict
  + 2. Sending a dict with an empty string
  + """
  + data = await request.json()
  + if 'version' in data.keys():
  + ignored_version = data.get('version')
  + log.debug('Set Ignore Version to {}'.format(ignored_version))
  + if ignored_version == '':
  + status = 400
  + res = {'version': None}
  + else:
  + _set_ignored_version(ignored_version)
  + status = 200
  + res = {'version': ignored_version}
  + else:
  + status = 400
  + res = {'version': None}
  +
  + return web.json_response(res, status=status)
  +
  +
  async def update_api(request: web.Request) -> web.Response:
  """
  This handler accepts a POST request with Content-Type: multipart/form-data
  