mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-27 16:10:58 +01:00
Added reply rule
This commit is contained in:
@@ -24,6 +24,9 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
@@ -47,6 +50,25 @@ public class EntityAnswer implements Serializable {
|
||||
@NonNull
|
||||
public String text;
|
||||
|
||||
static String getAnswerText(DB db, long id, Address[] from) {
|
||||
EntityAnswer answer = db.answer().getAnswer(id);
|
||||
if (answer == null)
|
||||
return null;
|
||||
|
||||
String name = null;
|
||||
String email = null;
|
||||
if (from != null && from.length > 0) {
|
||||
name = ((InternetAddress) from[0]).getPersonal();
|
||||
email = ((InternetAddress) from[0]).getAddress();
|
||||
}
|
||||
|
||||
String text = answer.text;
|
||||
text = text.replace("$name$", name == null ? "" : name);
|
||||
text = text.replace("$email$", email == null ? "" : email);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", name);
|
||||
@@ -71,4 +93,10 @@ public class EntityAnswer implements Serializable {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user