const configs = require("../configs");
const Library = require("../library");

const logSave = async (
  token,
  device_id,
  remote_name,
  remote_type,
  operating_type
) => {
  if (token === configs.verifyToken) {
    try {
      const result = await Library.saveDeviceLog(
        device_id,
        remote_name,
        remote_type,
        operating_type
      );

      return result;
    } catch (error) {
      throw new Error("Mongodb'ye kaydedilirken hata oluştu (log.controller)");
    }
  } else {
    throw new Error("Hatalı token (log.controller)");
  }
};

module.exports = { logSave };
