Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

FIX #125 #130

Merged
merged 7 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/AuthIVAOController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function sso(Request $request, $url = "home")

$base_url = $openid_data["authorization_endpoint"];
$reponse_type = "code";
$scopes = "profile friends:read friends:write flight_plans:read flight_plans:write";
$scopes = "profile friends:read friends:write flight_plans:read flight_plans:write tracker";
$state = rand(100000, 999999); // Random string to prevent CSRF attacks

$query = [
Expand Down
77 changes: 47 additions & 30 deletions app/Http/Controllers/DiscordContoller.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function push_github(Request $request)
public function description(Request $request)
{
$text = $request->body;
if($request->link != null){
return "Type:".$request->labels." \n\n". $text .= "\n\n Link direct github: [Issue](" . $request->link . ")";
}else{
return "Type:".$request->labels." \n\n". $text;
if ($request->link != null) {
return "Type:" . $request->labels . " \n\n" . $text .= "\n\n Link direct github: [Issue](" . $request->link . ")";
} else {
return "Type:" . $request->labels . " \n\n" . $text;
}
}

Expand All @@ -54,37 +54,56 @@ public function send_feedback(Request $request)
"body" => $request->body,
"user_id" => $request->user_id,
"labels" => $request->labels,
"link"=> $request->link,
"link" => $request->link,
]);
$usersController = new UsersController();
$user = $usersController->get_info_user($request->user_id);
if(!$user){
$user = [
"name" => "Anonymous",
"vid" => "0000000",
];
}
$push = Http::post($this->url_webhooks(), [
"avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg",
"embeds" => [
[
"title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")",
"description" => $this->description($request),
"url" => $request->link ?? null,
"color" => "16711680",
"footer" => [
"text" => "Feedback Form the website",
],
"timestamp" => date("Y-m-d H:i:s")
if (!$user) {
$user = [
"name" => "Anonymous",
"vid" => "0000000",
];
$push = Http::post($this->url_webhooks(), [
"avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg",
"embeds" => [
[
"title" => "Feedback from: " . $user["name"],
"description" => $this->description($request),
"url" => $request->link ?? null,
"color" => "16711680",
"footer" => [
"text" => "Feedback Form the website",
],
"timestamp" => date("Y-m-d H:i:s")
]
]
]

]);
return $push;
]);
return $push;
} else {
$push = Http::post($this->url_webhooks(), [
"avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg",
"embeds" => [
[
"title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")",
"description" => $this->description($request),
"url" => $request->link ?? null,
"color" => "16711680",
"footer" => [
"text" => "Feedback Form the website",
],
"timestamp" => date("Y-m-d H:i:s")
]
]

]);
return $push;
}
}

public function url_discord_for_code(Request $request){
$url = "https://discord.com/api/oauth2/authorize?client_id=".env("discord_client_id")."&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Ftest2&response_type=code&scope=identify";
public function url_discord_for_code(Request $request)
{
$url = "https://discord.com/api/oauth2/authorize?client_id=" . env("discord_client_id") . "&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Ftest2&response_type=code&scope=identify";
$request->merge([
"code" => $request->code,
]);
Expand All @@ -94,6 +113,4 @@ public function url_discord_for_code(Request $request){
];
return $url["code"];
}


}
74 changes: 49 additions & 25 deletions app/Http/Controllers/GithubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,79 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Http;
use App\Http\Controllers\DiscordContoller;


class GithubController extends Controller
{
public function url_issue(){
$url = "https://api.github.com/repos/alexcaussades/L10/issues";
public function url_issue()
{
$url = "https://api.github.com/repos/alexcaussades/Ivatrac/issues";
return $url;
}

public function token(){
public function token()
{
$token = env('Github_token_issue');
return $token;
}

public function call_API(){
public function call_API()
{
$f = http::withToken($this->token())->post($this->url_issue());
return $f;

}

public function send_issue(Request $request){
public function send_issue(Request $request)
{
/** Send issue to github on the repo alexcaussades/l10 is token is valid*/

$users = new UsersController();

$user = $users->get_info_user($request->user_id);
if(!$user){
$users = [
if (!$user) {
$user = [];
$user = [
"name" => "Anonymous",
"vid" => "Anonymous"
];
$issue = Http::withToken($this->token())->post($this->url_issue(), [
"title" => "Feedback from: " . $user["name"],
"body" => $request->body,
"labels" => [
$request->labels
]
]);
/** header location de l'issue */
$url = $this->return_url($issue);
return $url["html_url"];
} else {
$issue = Http::withToken($this->token())->post($this->url_issue(), [
"title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")",
"body" => $request->body,
"labels" => [
$request->labels
]
]);
/** header location de l'issue */
$url = $this->return_url($issue);
return $url["html_url"];
}
$issue = Http::withToken($this->token())->post($this->url_issue(), [
"title" => "Feedback from: " . $user->name . " (VID: ".$user->vid.")",
"body" => $request->body,
"labels" => [
$request->labels
]
]);
/** header location de l'issue */
$url = $this->return_url($issue->header('location'));
return $url;
}

public function return_url($url){
$url = explode("/", $url);
$new_url = "https://github.com/alexcaussades/L10/issues/" . $url[7];
return $new_url;

public function return_url($url)
{
$issue = $url->json();
$issue_post = [];
$issue_post = [
"url" => $issue["url"],
"html_url" => $issue["html_url"],
"repository_url" => $issue["repository_url"],
"labels" => $issue["labels"],
"title" => $issue["title"],
];
return $issue_post;
}
}

3 changes: 1 addition & 2 deletions app/Http/Controllers/usersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function connect_via_ivao($request, $data)
'vid' => $data["id"],
'name_first' => $data["firstName"],
'name_last' => $data["lastName"],
'email' => $data["email"],
'email' => $data["email"] ?? "null",
'password' => Hash::make("ivao"),
'email_verified_at' => now(),
'remember_token' => Str::random(10),
Expand Down Expand Up @@ -188,7 +188,6 @@ public function logout(Request $request)
$request->session()->forget('remember_token');
$request->session()->forget('ivao_tokens');
$request->session()->flush();

}

public function get_info_user($id)
Expand Down
42 changes: 33 additions & 9 deletions app/Http/Controllers/whazzupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,34 @@ public function user_me()
$users_me = $users_me->json();
$users_me = collect($users_me);
$users_me = $users_me->toArray();


/** convertir timestant uniquement en heure en addition des jours */
$heure = Carbon::createFromTimestamp(0)->format('Y-m-d H:i:s');
$atc = Carbon::createFromTimestamp($users_me["hours"][0]["hours"])->format('Y-m-d H:i:s');
$atc = Carbon::createFromTimestamp($users_me["hours"][0]["hours"])->format('Y-m-d H:i');
/** diff entre heure et minutes $atc */
$atc1 = Carbon::parse($atc);
$heure = Carbon::parse($heure);
$atc = $atc1->diffInHours($heure);
$atc = $atc1->diffInMinutes($heure) / 60;
$heure = Carbon::createFromTimestamp($users_me["hours"][1]["hours"])->format('Y-m-d H:i:s');
$heure = Carbon::parse($heure);
$heure = $heure->diffInHours($heure);

/** Rounded heure ATC */
$atc = round($atc, 2);

/** Pilot */
$pilot = Carbon::createFromTimestamp($users_me["hours"][1]["hours"])->format('Y-m-d H:i');
$pilot1 = Carbon::parse($pilot);
$pilot = $pilot1->diffInHours($heure);
$pilot = $pilot1->diffInMinutes($heure) / 60;
/** Rounded heure Pilot */
$pilot = round($pilot, 2);

/** Staff */
$staff = Carbon::createFromTimestamp($users_me["hours"][2]["hours"])->format('Y-m-d H:i');
$staff1 = Carbon::parse($staff);
$staff = $staff1->diffInHours($heure);
$staff = $staff1->diffInMinutes($heure) / 60;
/** Rounded heure Staff */
$staff = round($staff, 2);



Expand All @@ -361,10 +377,10 @@ public function user_me()
"Hours" => [
/** conversion value timestamp en heure */

"AtcHours" => Carbon::createFromTimestamp($users_me["hours"][0]["hours"]),
"PilotHours" => $users_me["hours"][1]["hours"],
"StaffHours" => $users_me["hours"][2]["hours"],
"TotalHours" => null,
"AtcHours" => $atc,
"PilotHours" => $pilot,
"StaffHours" => $staff,
"TotalHours" => $atc + $pilot,


],
Expand Down Expand Up @@ -633,4 +649,12 @@ public function get_aircrafts($icao_code)
return $aircrafts;

}

public function event_ivao()
{
$event = $this->API_request("/v1/events");
$event = $event->json();
return $event;
}

}
Loading
Loading