<commit_before>package ie.gmit.sw.services;

import ie.gmit.sw.controllers.requests.MailTokenRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;


@Service("emailService")
public class EmailService {

    private static final Logger LOGGER = LoggerFactory.getLogger(EmailService.class);
    private RestTemplate restTemplate;

    @Value("${gateway.gateway-path}")
    String appUrl;// need change to zuul url later
    @Value("${gateway.email-path}")
    String emailUrl;

    @Autowired
    public EmailService(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @Async("executor")
    public void sendEmail(String email, String token) {

        LOGGER.info("@@@@@@@@@@ Email Sender Service thread: "
                + Thread.currentThread().getName());

        List<String> to = new ArrayList<>();
        MailTokenRequest tokenMail = new MailTokenRequest();
        to.add(email);

        tokenMail.setTo(to);
        tokenMail.setSubject("Registration Confirmation");
        tokenMail.setText("To confirm your e-mail address, please click the link below:\n"
                + appUrl + "/verify/" + token);
        tokenMail.setFrom("<EMAIL>");

        // send email
/*
        SimpleMailMessage registrationEmail = new SimpleMailMessage();
        registrationEmail.setTo(email);
        registrationEmail.setSubject("Registration Confirmation");
        registrationEmail.setText("To confirm your e-mail address, please click the link below:\n"
                + appUrl + "/verify/" + token);
        registrationEmail.setFrom("<EMAIL>"); */<commit_msg>Changing URL sent in email to point to API via gateway<commit_after>package ie.gmit.sw.services;

import ie.gmit.sw.controllers.requests.MailTokenRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;


@Service("emailService")
public class EmailService {

    private static final Logger LOGGER = LoggerFactory.getLogger(EmailService.class);
    private RestTemplate restTemplate;

    @Value("${gateway.gateway-path}")
    String appUrl;// need change to zuul url later
    @Value("${gateway.email-path}")
    String emailUrl;

    @Autowired
    public EmailService(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @Async("executor")
    public void sendEmail(String email, String token) {

        LOGGER.info("@@@@@@@@@@ Email Sender Service thread: "
                + Thread.currentThread().getName());

        List<String> to = new ArrayList<>();
        MailTokenRequest tokenMail = new MailTokenRequest();
        to.add(email);

        tokenMail.setTo(to);
        tokenMail.setSubject("Registration Confirmation");
        tokenMail.setText("To confirm your e-mail address, please click the link below:\n"
                + appUrl + "/reg/verify/" + token); // use API root defined in Zuul
                                                    // Registration API /reg/ in this case
        tokenMail.setFrom("<EMAIL>");

        // send email
/*
        SimpleMailMessage registrationEmail = new SimpleMailMessage();
        registrationEmail.setTo(email);
        registrationEmail.setSubject("Registration Confirmation");
        registrationEmail.setText("To confirm your e-mail address, please click the link below:\n"
                + appUrl + "/verify/" + token);
        registrationEmail.setFrom("<EMAIL>"); */
{'fraction_non_alphanumeric': 0.11221042471042471, 'fraction_numerical': 0.0009652509652509653, 'mean_word_length': 3.363157894736842, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5109923', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1082, 'n_words': 256}