-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
52f4cb7
commit 4d3fd4c
Showing
40 changed files
with
895 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "Automated alert" | ||
|
||
on: | ||
issues: | ||
types: | ||
- labeled | ||
|
||
jobs: | ||
comment: | ||
name: "Comment to notify" | ||
if: ${{ github.event.label.name == 'is:automated' }} | ||
timeout-minutes: 2 | ||
|
||
permissions: | ||
issues: write | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Comment on issue to trigger notification." | ||
env: | ||
GH_REPO: ${{ github.repository }} | ||
GH_TOKEN: ${{ github.token }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
COMMENT_BODY: | | ||
Automated notification alert. | ||
-- _This comment was created by a [GitHub Actions Workflow][workflow]'s [run][run]._ | ||
[workflow]: ${{ github.server_url }}/${{ github.repository }}/actions/workflows/automated-alert.yml | ||
[run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
shell: bash | ||
run: | ||
gh issue comment "${ISSUE_NUMBER}" --body "${COMMENT_BODY}" |
30 changes: 0 additions & 30 deletions
30
...d/app/full/src/main/java/net/twisterrob/android/utils/concurrent/MailSenderAsyncTask.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,12 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import net.twisterrob.android.AndroidConstants; | ||
import net.twisterrob.android.app.BaseApp; | ||
import net.twisterrob.android.log.AndroidLoggerFactory; | ||
import net.twisterrob.android.utils.concurrent.BackgroundExecution; | ||
import net.twisterrob.android.utils.concurrent.MailSenderAsyncTask; | ||
import net.twisterrob.android.utils.tostring.stringers.detailed.RangeStringers; | ||
import net.twisterrob.blt.android.app.full.BuildConfig; | ||
import net.twisterrob.blt.android.data.AndroidDBStaticData; | ||
|
@@ -80,21 +77,6 @@ public AndroidStaticData getStaticData() { | |
return m_static; | ||
} | ||
|
||
public static void sendMail(String body) { | ||
@SuppressWarnings({"unused", "deprecation"}) // TODO https://github.com/TWiStErRob/net.twisterrob.travel/issues/15 | ||
Object task = new MailSenderAsyncTask("Better London Travel", | ||
"[email protected]", "[email protected]") { | ||
@Override protected void onPostExecute(Boolean result) { | ||
super.onPostExecute(result); | ||
if (Boolean.TRUE.equals(result)) { | ||
Toast.makeText(getInstance(), "Mail sent", Toast.LENGTH_SHORT).show(); | ||
} else { | ||
Toast.makeText(getInstance(), "Mail failed", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
}.execute(body); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override public Injector injector() { | ||
return new net.twisterrob.blt.android.ui.activity.Injector( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,19 @@ | |
import org.xml.sax.helpers.DefaultHandler; | ||
|
||
import net.twisterrob.java.exceptions.StackTrace; | ||
import net.twisterrob.java.io.MailSender; | ||
import net.twisterrob.java.io.FeedbackSender; | ||
|
||
public abstract class BaseFeedHandler<T extends BaseFeed<T>> extends DefaultHandler implements FeedHandler<T> { | ||
public final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
|
||
protected static void sendMail(String body) { | ||
MailSender sender = new MailSender(); | ||
sender.setSubject("Better London Travel"); | ||
sender.setFrom("[email protected]"); | ||
sender.setTos("[email protected]"); | ||
sender.setBody(body); | ||
protected static void sendFeedback(String title, String body) { | ||
String envs = System.getProperty("micronaut.environments"); | ||
if (envs == null || !envs.contains("production")) { | ||
throw new IllegalStateException("Immediate feedback: " + title + "\n" + body); | ||
} | ||
FeedbackSender sender = new FeedbackSender(); | ||
try { | ||
sender.send(); | ||
sender.send(title, body); | ||
} catch (Exception e) { | ||
String callingClass = new StackTrace().getStackTrace()[1].getClassName(); | ||
Logger log = LoggerFactory.getLogger(callingClass); | ||
|
54 changes: 54 additions & 0 deletions
54
common/feed/core/src/main/java/net/twisterrob/java/io/FeedbackSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package net.twisterrob.java.io; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.HttpURLConnection; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLEncoder; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class FeedbackSender { | ||
|
||
public void send(@Nullable String title, @Nonnull String body) throws IOException { | ||
try { | ||
URL url = buildUrl(title); | ||
HttpURLConnection conn = (HttpURLConnection)url.openConnection(); | ||
conn.setDoInput(true); | ||
conn.setDoOutput(true); | ||
conn.setRequestMethod("POST"); | ||
conn.connect(); | ||
try { | ||
IOTools.writeAll(conn.getOutputStream(), body); | ||
InputStream response = new BufferedInputStream(conn.getInputStream()); | ||
String result = IOTools.readAll(response, "UTF-8"); | ||
if (!result.trim().isEmpty()) { | ||
throw new IOException("Server responded with: " + result); | ||
} | ||
} finally { | ||
conn.disconnect(); | ||
} | ||
} catch (IOException ex) { | ||
throw new IOException("Cannot send " + title, ex); | ||
} | ||
} | ||
|
||
private static @Nonnull URL buildUrl(String title) | ||
throws UnsupportedEncodingException, MalformedURLException { | ||
String titleQuery; | ||
if (title != null) { | ||
String escapedTitle = URLEncoder.encode(title, "UTF-8"); | ||
titleQuery = "title=" + escapedTitle; | ||
} else { | ||
titleQuery = ""; | ||
} | ||
return new URL( | ||
"https://twisterrob-london.appspot.com/InternalFeedback?" | ||
+ titleQuery | ||
); | ||
} | ||
} |
74 changes: 0 additions & 74 deletions
74
common/feed/core/src/main/java/net/twisterrob/java/io/MailSender.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.