Skip to content

Commit

Permalink
Fixed processor, script modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jc0b committed Feb 7, 2023
1 parent d71f3f7 commit eba8730
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
25 changes: 18 additions & 7 deletions kandji_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function run($plist)
$parser = new CFPropertyList();
$parser->parse($plist, CFPropertyList::FORMAT_XML);
$mylist = $parser->toArray();

echo "Parsed plist";
// Retrieve Kandji MR record (if existing)
try {
$model = Kandji_model::select()
Expand All @@ -33,8 +33,6 @@ public function run($plist)
$model = new Kandji_model();
}

$model->fill($mylist);

// Check if we should enable Kandji lookup
if (conf('kandji_enable')) {
// Load Kandji helper
Expand All @@ -48,9 +46,9 @@ public function run($plist)
$mylist['asset_tag'] = $json[0]->asset_tag;
$mylist['blueprint_id'] = $json[0]->blueprint_id;
$mylist['blueprint_name'] = $json[0]->blueprint_name;
$mylist['last_check_in'] = $kandji_helper->convert_time_to_epoch($json[0]->last_check_in);
$mylist['last_enrollment'] = $kandji_helper->convert_time_to_epoch($json[0]->last_enrollment);
$mylist['first_enrollment'] = $kandji_helper->convert_time_to_epoch($json[0]->first_enrollment);
$mylist['last_check_in'] = $this->convert_time_to_epoch($json[0]->last_check_in);
$mylist['last_enrollment'] = $this->convert_time_to_epoch($json[0]->last_enrollment);
$mylist['first_enrollment'] = $this->convert_time_to_epoch($json[0]->first_enrollment);

// Location section
$mylist['realname'] = $json[0]->user->name;
Expand All @@ -60,4 +58,17 @@ public function run($plist)

$model->fill($mylist)->save();
}
}

/**
* Convert Kandji timestamps to epochs
*
* @return Unix epoch
* @author jc0b
*
**/
private function convert_time_to_epoch($date)
{
$dt = new \DateTime($date);
return $dt->getTimestamp();
}
}
14 changes: 0 additions & 14 deletions lib/kandji_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,4 @@ public function send_kandji_query($url)

return $return;
}


/**
* Convert Kandji timestamps to epochs
*
* @return Unix epoch
* @author jc0b
*
**/
private function convert_time_to_epoch($date)
{
$dt = new \DateTime($date);
return $dt->getTimestamp();
}
}
2 changes: 1 addition & 1 deletion scripts/kandji.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main():
result = get_local_kandji_prefs()
passport_users = get_passport_info()
if len(passport_users) > 0:
result['passport_enabled'] = True
result['passport_enabled'] = "True"
result['passport_users'] = passport_users

# Write results to cache
Expand Down

0 comments on commit eba8730

Please sign in to comment.