Commit fc1f9cde authored by Dominik Hebeler's avatar Dominik Hebeler

switched contact mail to directly post to ticket system

parent 2f348141
......@@ -155,7 +155,7 @@ class RequestFetcher extends Command
Log::error($error);
}
if ($responseCode !== 200) {
if ($responseCode !== 200 && $responseCode !== 201) {
Log::debug($resulthash);
Log::debug("Got responsecode " . $responseCode . " fetching \"" . curl_getinfo($info["handle"], CURLINFO_EFFECTIVE_URL) . "\n");
} else {
......
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Mail\Kontakt;
use App\Mail\Sprachdatei;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Http\Response;
use LaravelLocalization;
use Mail;
......@@ -58,31 +59,83 @@ class MailController extends Controller
$messageType = "error";
$returnMessage = trans('kontakt.error.1');
} else {
# Wir versenden die Mail des Benutzers an uns:
$mailto = "support@metager.org";
if (LaravelLocalization::getCurrentLocale() === "de") {
$mailto = "support+46521@metager.de";
}
$message = $request->input('message');
$subject = $request->input('subject');
$files = [];
# Wir versenden die Mail des Benutzers an uns:
$postdata = [
"alert" => true,
"autorespond" => true,
"source" => "API",
"name" => $name,
"email" => $replyTo,
"subject" => $subject,
"ip" => $request->ip(),
"deptId" => 5,
"message" => "data:text/plain, $message",
"attachments" => [
//["file.txt" => "data:text/plain;charset=utf-8,content"]
]
];
if($request->has("attachments") && is_array($request->file("attachments"))){
$files = $request->file("attachments");
}
foreach($request->file("attachments") as $attachment){
$postdata["attachments"][] = [
$attachment->getClientOriginalName() => "data:" . $attachment->getMimeType() . ";base64," . base64_encode(file_get_contents($attachment->getRealPath()))
];
}
}
Mail::to($mailto)
->send(new Kontakt($name, $replyTo, $subject, $message, $files));
if (LaravelLocalization::getCurrentLocale() === "de") {
$postdata["deptId"] = 1;
}
$returnMessage = trans('kontakt.success.1');
$messageType = "success";
$postdata = json_encode($postdata);
$resulthash = md5($subject . $message);
$mission = [
"resulthash" => $resulthash,
"url" => env("TICKET_URL", "https://metager.de"),
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => null,
"password" => null,
"headers" => [
"X-API-Key" => env("TICKET_APIKEY", ""),
"Content-Type" => "application/json",
"Content-Length" => strlen($postdata)
],
"cacheDuration" => 0,
"name" => "Ticket",
"curlopts" => [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_LOW_SPEED_TIME => 20,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 20
]
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
// Fetch the result
$answer = Redis::blpop($resulthash, 20);
// Fehlerfall
if(empty($answer) || (is_array($answer) && sizeof($answer) === 2 && $answer[1] === "no-result")){
$messageType = "error";
$returnMessage = trans('kontakt.error.2', ["email" => env("MAIL_USERNAME", "support+46521@metager.de")]);
}else{
$returnMessage = trans('kontakt.success.1', ["email" => $replyTo]);
$messageType = "success";
}
}
return view('kontakt.kontakt')
->with('title', 'Kontakt')
->with('js', ['lib.js'])
->with($messageType, $returnMessage);
}
public function donation(Request $request)
......
......@@ -19,5 +19,6 @@ Röselerstr. 3
30159 Hannover
Germany',
'error.1' => 'Tut uns leid, aber leider haben wir mit Ihrer Kontaktanfrage keine Daten erhalten. Die Nachricht wurde nicht versandt.',
'success.1' => 'Ihre Nachricht wurde uns erfolgreich zugestellt. Vielen Dank dafür! Wir werden diese schnellstmöglich bearbeiten und uns dann ggf. wieder bei Ihnen melden.'
"error.2" => 'Beim Versand Ihrer Nachricht ist ein Fehler aufgetreten. Sie können uns direkt unter folgender E-Mail Adresse kontaktieren: :email',
'success.1' => 'Ihre Nachricht wurde uns erfolgreich zugestellt. Eine erste automatische Bestätigung haben wir an :email gesendet.'
];
......@@ -17,5 +17,6 @@ Röselerstr. 3
30159 Hannover
Germany',
'error.1' => 'We are sorry, but unfortunately we did not receive any data with your contact request. The message was not sent.',
'success.1' => 'Your message was successfully sent to us. Thanks a lot for this! We will process this as soon as possible and then contact you again if necessary.'
"error.2" => 'There was an error delivering your message. You can contact us directly under :email',
'success.1' => 'Your message was delivered successfully. A first automatic reply was sent to :email.'
];
......@@ -17,19 +17,19 @@
{{ csrf_field() }}
<input type="hidden" name="pcsrf" value="{{ base64_encode(\time()) }}">
<div class="form-group kontakt-form-group">
<input class="form-control" name="name" placeholder="{!!trans('kontakt.form.name')!!}" type="text" required @if(isset($formerrors) && Request::has('name'))value="{{Request::input('name')}}"@endif>
<input class="form-control" name="name" placeholder="{!!trans('kontakt.form.name')!!}" type="text" required @if((isset($formerrors) || !empty($error)) && Request::has('name'))value="{{Request::input('name')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="email" required @if(isset($formerrors) && Request::has('email'))value="{{Request::input('email')}}"@endif>
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="email" required @if((isset($formerrors) || !empty($error)) && Request::has('email'))value="{{Request::input('email')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="subject" placeholder="{!! trans('kontakt.form.7') !!}" type="text" required @if(isset($formerrors) && Request::has('subject'))value="{{Request::input('subject')}}"@endif>
<input class="form-control" name="subject" placeholder="{!! trans('kontakt.form.7') !!}" type="text" required @if((isset($formerrors) || !empty($error)) && Request::has('subject'))value="{{Request::input('subject')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
@if(isset($url) && $url !== "")
<label for="message">Wenn MetaGer bestimmte Webseiten nicht angezeigt hat, von denen Sie wissen, dass es sie gibt: Bitte nennen Sie deren Adresse/n (http:// ...???...). Wir werden das detailliert untersuchen.</label>
@endif
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}" required>@if(isset($formerrors) && Request::has('message')){{Request::input('message')}}@endif</textarea>
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}" required>@if((isset($formerrors) || !empty($error)) && Request::has('message')){{Request::input('message')}}@endif</textarea>
</div>
<div class="form-group kontakt-form-group">
<label for="attachments">@lang("kontakt.form.9")</label>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment