Skip to content

Commit

Permalink
Merge pull request #878 from prey/Fix/mac-sonoma-fix
Browse files Browse the repository at this point in the history
fix(missing-report): delete unnecessary code and refactor
  • Loading branch information
beregcamlost authored Sep 27, 2023
2 parents f72cea1 + 67b2ae1 commit cafb4aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
8 changes: 2 additions & 6 deletions lib/agent/providers/screenshot/mac/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ const done = (err, filePath, cb) => {
};
/**
* Configures the screenshot user data.
*
* @param {string} user - the user's name
* @param {number} userId - the user's ID
*/
const configureScreenshotUserData = (user) => {
screenshotUtilData.userPath = `/Users/${user}`;
const configureScreenshotUserData = () => {
screenshotUtilData.appPath = `${__dirname}/../../../utils/Prey.app`;
screenshotUtilData.screenshotDir = '/tmp';
screenshotUtilData.tmpScreenshot = `${screenshotUtilData.screenshotDir}/screenshot.jpg`;
Expand Down Expand Up @@ -98,7 +94,7 @@ exports.get_screenshot = (callback) => {
common.system.get_logged_user((err, user) => {
if (err || !user) return done(new Error(`Unable to get logged user: ${err.toString()}`), null, callback);
// eslint-disable-next-line consistent-return
configureScreenshotUserData(user);
configureScreenshotUserData();
// eslint-disable-next-line consistent-return
takeScreenshot((errorTakescreenshot) => {
if (errorTakescreenshot) return done(errorTakescreenshot, null, callback);
Expand Down
26 changes: 4 additions & 22 deletions lib/agent/providers/webcam/mac/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ let child;
let running = true;

const pictureUtilData = {
userPath: '',
picturePath: '',
appPath: '',
pictureDir: '',
tmpPicture: '',
Expand All @@ -43,25 +41,10 @@ const done = (err, filePath, cb) => {
* @param {string} user - the user's name
* @param {number} userId - the user's ID
*/
const configurePictureUserData = (user) => {
pictureUtilData.userPath = `/Users/${user}`;
const configurePictureUserData = () => {
pictureUtilData.appPath = `${__dirname}/../../../utils/Prey.app`;
pictureUtilData.tmpPicture = `${pictureUtilData.pictureDir}/picture.${process.pid}.jpg`;
};
/**
* Retrieves the user ID for the given user.
*
* @param {string} user - The username of the user.
* @param {function} cb - The callback function to be executed after retrieving the user ID.
* @return {undefined} This function does not return a value.
*/
const getIdUser = (user, cb) => {
// eslint-disable-next-line consistent-return
exec(`id -u ${user}`, (err, userId) => {
if (err || !userId) return cb(err);
configurePictureUserData(user, userId);
cb();
});
pictureUtilData.pictureDir = '/tmp';
pictureUtilData.tmpPicture = `${pictureUtilData.pictureDir}/picture.jpg`;
};

/**
Expand Down Expand Up @@ -102,7 +85,7 @@ exports.get_picture = (callback) => {
common.system.get_logged_user((err, user) => {
if (err || !user) return done(new Error(`Unable to get logged user: ${err.toString()}`), null, callback);
// eslint-disable-next-line consistent-return
configurePictureUserData(user);
configurePictureUserData();
// eslint-disable-next-line consistent-return
takePicture((errorTakePicture) => {
if (errorTakePicture) return done(errorTakePicture, null, callback);
Expand All @@ -116,7 +99,6 @@ exports.get_picture = (callback) => {
exports.done = done;
exports.running = running;
exports.timer = timer;
exports.getIdUser = getIdUser;
exports.pictureUtilData = pictureUtilData;
exports.configurePictureUserData = configurePictureUserData;
exports.takePicture = takePicture;

0 comments on commit cafb4aa

Please sign in to comment.