no message

This commit is contained in:
2024-09-24 23:34:41 +03:00
parent 33e6abfbf5
commit bb671c5166
12 changed files with 40 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
package Repository.BugReport;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.Utils.TextLog;
@@ -64,20 +65,14 @@ public class BugReportInterface {
public static String getMailTitlePrefix(BugReport object) {
return "Ошибка " + Utils.Brackets(object.id) + ", автор " + Utils.Brackets(object.sender_name) + " : ";
}
public static Vector<String> getRecipients(BugReport object, boolean add_defaults) {
public static Vector<String> getRecipients(BugReport object) {
Vector<String> res = new Vector<>();
String[] data = object.targets.split("\n");
for (String a : data)
if (a.length() > 0)
res.add(a);
if (add_defaults) {
// res.add(Email.full_address); //служебный ящик
//добавить админов если их там нет.
Arrays.stream(Global.admins_mails).filter(adm -> !res.contains(adm)).forEach(res::add);
// и себя
if (!res.contains(Current.getAccount().email))
res.add(Current.getAccount().email);
}
if (!res.contains(Current.getAccount().email))
res.add(Current.getAccount().email);
return res;
}
public static File[] getAttachements(BugReport object) {

View File

@@ -105,9 +105,8 @@ public abstract class RepositoryServer<D extends Database> {
Utils.unpackFile(message_in.files.get(aName), f);
innerFiles.put(aName, f);
}
Vector<String> targets_ = new Vector<>();
targets_.add(Constants.MailAddress); //себе.
targets_.addAll(message_in.targets);
Vector<String> targets_ = new Vector<>(message_in.targets);
Utils.addDefaultMails(targets_);
//------------------------------
Session session = Session.getDefaultInstance(props,
new Authenticator() {

View File

@@ -1,4 +1,5 @@
package Repository.Server;
import Common.Constants;
import Common.Database.DBObject;
import Common.Global;
import Common.Utils.Utils;
@@ -61,11 +62,10 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
@Override
public void StartAction() throws Exception {
if (Global.properties.EmailAdminsOnStart) {
Vector<String> targets = new Vector<>(Arrays.asList(Global.admins_mails));
EmailMessage message = new EmailMessage(
"Сервер Sapfor запущен",
new Date().toString(),
targets
new Vector<>()
);
Email(message);
}
@@ -405,12 +405,10 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
}
//bonus backup
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
Vector<String> targets = new Vector<>();
targets.addAll(Arrays.asList(Global.admins_mails));
EmailMessage message = new EmailMessage(
"db backup",
"копия баз данных журнала ошибок",
targets
new Vector<>()
);
Email(message, db.getFile());
}