This commit is contained in:
Roman Volosovskyi 2019-04-30 08:18:05 +03:00
parent 4041a12612
commit ff39426e56
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
16 changed files with 70 additions and 35 deletions

View File

@ -271,6 +271,7 @@ dependencies {
implementation project(':react-native-webview')
implementation project(':react-native-config')
implementation project(':react-native-firebase')
implementation project(':RNMail')
compile ('com.google.android.gms:play-services-base:16.0.1') {
force = true
}

View File

@ -35,6 +35,7 @@ import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
import io.realm.react.RealmReactPackage;
import me.alwx.HttpServer.HttpServerReactPackage;
import com.chirag.RNMail.*;
public class MainApplication extends MultiDexApplication implements ReactApplication {
@ -50,6 +51,7 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
Function<String, String> callRPC = statusPackage.getCallRPC();
return Arrays.asList(
new MainReactPackage(),
new RNMail(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage(),

View File

@ -42,3 +42,5 @@ include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-android'
project(':react-native-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
include ':RNMail', ':app'
project(':RNMail').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mail/android')

View File

@ -43,7 +43,8 @@
"text-encoding"
"js-sha3"
"react-navigation"
"hi-base32"]
"hi-base32"
"react-native-mail"]
;; Desktop modules
:desktop-modules ["realm"

View File

@ -48,6 +48,7 @@
"react-native-invertible-scroll-view": "1.1.0",
"react-native-keychain": "git+https://github.com/status-im/react-native-keychain.git#v.3.0.0-status",
"react-native-languages": "^3.0.2",
"react-native-mail": "git+https://github.com/status-im/react-native-mail.git#v3.0.8_status",
"react-native-os": "git+https://github.com/status-im/react-native-os.git#v1.1.0-1-status",
"react-native-qrcode": "git+https://github.com/status-im/react-native-qrcode.git#v0.2.8",
"react-native-randombytes": "3.5.0",

View File

@ -5527,6 +5527,10 @@ react-native-languages@^3.0.2:
resolved "https://registry.yarnpkg.com/react-native-languages/-/react-native-languages-3.0.2.tgz#c2c4c5050974fe4b50f7372051ca1f9824c1c778"
integrity sha512-LGsTfixFM6hXDhcFJI6mrtrNBsGPSvXT9RtZQ0tlqmGFKmMyZW6eQgJ7kLw8lISD2FIGl4jJwY06EAJpbMsNxg==
"react-native-mail@git+https://github.com/status-im/react-native-mail.git#v3.0.8_status":
version "3.0.7"
resolved "git+https://github.com/status-im/react-native-mail.git#5dd2d4e92fa696a9dd0efebdc530df22772326fe"
"react-native-os@git+https://github.com/status-im/react-native-os.git#v1.1.0-1-status":
version "1.1.0"
resolved "git+https://github.com/status-im/react-native-os.git#1a6d0835f919cb075793ad7c602f2724eee4702d"

View File

@ -522,7 +522,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
}
out.close();
return true;
} catch (Exception e) {
Log.e(TAG, e.getMessage());
@ -557,9 +557,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
}
}).show();
}
@ReactMethod
public void sendLogs(final String dbJson) {
public void sendLogs(final String dbJson, final Callback callback) {
Log.d(TAG, "sendLogs");
if (!checkAvailability()) {
return;
@ -594,33 +594,14 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
return;
}
}
dumpAdbLogsTo(new FileOutputStream(statusLogFile));
final Stack<String> errorList = new Stack<String>();
final Boolean zipped = zip(new File[] {dbFile, gethLogFile, statusLogFile}, zipFile, errorList);
if (zipped && zipFile.exists()) {
Log.d(TAG, "Sending " + zipFile.getAbsolutePath() + " file through share intent");
final String providerName = context.getPackageName() + ".provider";
final Activity activity = getCurrentActivity();
zipFile.setReadable(true, false);
final Uri dbJsonURI = FileProvider.getUriForFile(activity, providerName, zipFile);
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
intentShareFile.setType("application/json");
intentShareFile.putExtra(Intent.EXTRA_STREAM, dbJsonURI);
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormatGmt.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
intentShareFile.putExtra(Intent.EXTRA_SUBJECT, "Status.im logs");
intentShareFile.putExtra(Intent.EXTRA_TEXT,
String.format("Logs from %s GMT\n\nThese logs have been generated automatically by the user's request for debugging purposes.\n\n%s",
dateFormatGmt.format(new java.util.Date()),
errorList));
activity.startActivity(Intent.createChooser(intentShareFile, "Share Debug Logs"));
callback.invoke(zipFile.getAbsolutePath());
} else {
Log.d(TAG, "File " + zipFile.getAbsolutePath() + " does not exist");
}

View File

@ -201,7 +201,7 @@ void showFileInGraphicalShell(QWidget *parent, const QFileInfo &fileInfo)
#endif
}
void RCTStatus::sendLogs(QString dbJSON) {
void RCTStatus::sendLogs(QString dbJSON, double callbackId) {
Q_D(RCTStatus);
qCDebug(RCTSTATUS) << "::sendLogs call - logFilePath:" << getLogFilePath()

View File

@ -39,7 +39,7 @@ public:
Q_INVOKABLE void stopNode();
Q_INVOKABLE void createAccount(QString password, double callbackId);
Q_INVOKABLE void sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId);
Q_INVOKABLE void sendLogs(QString dbJSON);
Q_INVOKABLE void sendLogs(QString dbJSON, double callbackId);
Q_INVOKABLE void addPeer(QString enode, double callbackId);
Q_INVOKABLE void recoverAccount(QString passphrase, QString password, double callbackId);
Q_INVOKABLE void login(QString address, QString password, double callbackId);

View File

@ -33,3 +33,4 @@
(def snoopy-buffer #js {})
(def background-timer #js {:setTimeout (fn [cb ms] (js/setTimeout cb ms))})
(def react-navigation (js/require "react-navigation"))
(def react-native-mail #js {:mail (fn [])})

View File

@ -28,6 +28,7 @@
(def snoopy-buffer (js/require "rn-snoopy/stream/buffer"))
(def background-timer (.-default (js/require "react-native-background-timer")))
(def react-navigation (js/require "react-navigation"))
(def react-native-mail (.-default (js/require "react-native-mail")))
(def desktop-linking #js {:addEventListener (fn [])})
(def desktop-menu #js {:addEventListener (fn [])})
(def desktop-config #js {:addEventListener (fn [])})

View File

@ -61,6 +61,8 @@ if [ ! -f .babelrc ] || [ $(readlink .babelrc) != "${PLATFORM_FOLDER}/.babelrc"
ln -sf ${PLATFORM_FOLDER}/metro.config.js metro.config.js
fi
rm -rf /home/jenkins/.cache/yarn/v4/.tmp/6ec8ff0e65cf4f48c50d7472fa1f10ca
rm -rf /Users/jenkins/Library/Caches/Yarn/v4/.tmp/6ec8ff0e65cf4f48c50d7472fa1f10ca
yarn install --frozen-lockfile
case $1 in

View File

@ -70,8 +70,8 @@
(defn send-data-notification [m callback]
(native-module/send-data-notification m callback))
(defn send-logs [dbJson]
(native-module/send-logs dbJson))
(defn send-logs [dbJson callback]
(native-module/send-logs dbJson callback))
(defn add-peer [enode callback]
(native-module/add-peer enode callback))

View File

@ -49,9 +49,9 @@
(when status
(.sendDataNotification status data-payload tokens on-result)))
(defn send-logs [dbJson]
(defn send-logs [dbJson callback]
(when status
(.sendLogs status dbJson)))
(.sendLogs status dbJson callback)))
(defn add-peer [enode on-result]
(when (and @node-started status)

View File

@ -0,0 +1,16 @@
(ns status-im.utils.email
(:require [re-frame.core :as re-frame]
[status-im.utils.fx :as fx]
[status-im.react-native.js-dependencies :as dependencies]))
(re-frame/reg-fx
:email/send
;; https://github.com/chirag04/react-native-mail#example
(fn [[opts callback]]
(.mail dependencies/react-native-mail
(clj->js opts)
callback)))
(fx/defn send-email
[_ opts callback]
{:email/send [opts callback]})

View File

@ -2,10 +2,21 @@
(:require [re-frame.core :as re-frame]
[status-im.native-module.core :as status]
[status-im.utils.fx :as fx]
[status-im.utils.types :as types]))
[status-im.utils.types :as types]
[status-im.utils.handlers :as handlers]
[status-im.utils.email :as mail]))
(def report-email "error-reports@status.im")
(re-frame/reg-fx
:logs/archive-logs
(fn [[db-json callback-handler]]
(status/send-logs
db-json
#(re-frame/dispatch [callback-handler %]))))
(fx/defn send-logs
[{:keys [db] :as cofx}]
[{:keys [db]}]
;; TODO: Add message explaining db export
(let [db-json (types/clj->json (select-keys db [:app-state
:current-chat-id
@ -29,4 +40,16 @@
:dimensions/window
:my-profile/editing?
:node/status]))]
(status/send-logs db-json)))
{:logs/archive-logs [db-json ::send-email]}))
(handlers/register-handler-fx
::send-email
(fn [cofx [_ archive-path]]
(mail/send-email cofx
{:subject "Error report"
:recipients [report-email]
:body "logs attached"
:attachment {:path archive-path
:type "zip"
:name "status_logs.zip"}}
(fn []))))