Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan url with QR scanner #7880

Closed
wants to merge 1 commit into from
Closed

Scan url with QR scanner #7880

wants to merge 1 commit into from

Conversation

krisc
Copy link

@krisc krisc commented Apr 3, 2019

This PR is for this bounty #5776

It fixes the issue as described, but I left it WIP because I'm not sure if additional checks have to be made or not. For example, if the qr-code returns data 30032621 should this show an error message or should it just navigate to whatever that data is in the browser?

If it should show an error, do we have a function already in status that checks for valid urls?

@status-im-auto
Copy link
Member

status-im-auto commented Apr 3, 2019

Jenkins Builds

Click to see older builds (28)
Commit #️⃣ Finished (UTC) Duration Platform Result
bdd280f #1 2019-04-03 03:47:49 ~3 min ios 📄 log
bdd280f #1 2019-04-03 03:49:22 ~4 min linux 📄 log
bdd280f #1 2019-04-03 03:49:22 ~4 min windows 📄 log
bdd280f #1 2019-04-03 03:50:13 ~5 min android 📄 log
bdd280f #1 2019-04-03 03:50:53 ~6 min android-e2e 📄 log
✔️ 5b54be8 #2 2019-04-03 19:58:12 ~17 min macos 📦 dmg
✔️ 5b54be8 #2 2019-04-03 19:59:30 ~18 min ios 📦 ipa
✔️ 5b54be8 #2 2019-04-03 20:04:01 ~22 min windows 📦 exe
✔️ 5b54be8 #2 2019-04-03 20:05:15 ~24 min linux 📦 App
✔️ 5b54be8 #2 2019-04-03 20:08:06 ~27 min android-e2e 📦 apk
✔️ 67a8933 #3 2019-04-04 20:50:30 ~15 min macos 📦 dmg
✔️ 67a8933 #3 2019-04-04 20:53:51 ~18 min ios 📦 ipa
✔️ 67a8933 #3 2019-04-04 20:56:28 ~21 min android 📦 apk
✔️ 67a8933 #3 2019-04-04 20:57:49 ~22 min windows 📦 exe
✔️ 67a8933 #3 2019-04-04 20:59:14 ~24 min linux 📦 App
✔️ 67a8933 #3 2019-04-04 20:59:55 ~25 min android-e2e 📦 apk
14a533e #4 2019-04-10 16:53:36 ~48 sec ios 📄 log
14a533e #4 2019-04-10 17:06:19 ~13 min macos 📄 log
✔️ 14a533e #4 2019-04-10 17:12:33 ~19 min android 📦 apk
✔️ 14a533e #4 2019-04-10 17:15:33 ~22 min android-e2e 📦 apk
✔️ 14a533e #4 2019-04-10 17:20:20 ~27 min linux 📦 App
✔️ 14a533e #4 2019-04-10 17:21:01 ~28 min windows 📦 exe
3336479 #5 2019-04-10 20:47:54 ~47 sec ios 📄 log
✔️ 3336479 #5 2019-04-10 21:01:20 ~14 min macos 📦 dmg
✔️ 3336479 #5 2019-04-10 21:05:01 ~17 min android 📦 apk
✔️ 3336479 #5 2019-04-10 21:07:06 ~20 min android-e2e 📦 apk
✔️ 3336479 #5 2019-04-10 21:11:44 ~24 min linux 📦 App
✔️ 3336479 #5 2019-04-10 21:12:28 ~25 min windows 📦 exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a28bc08 #6 2019-04-11 23:45:58 ~14 min macos 📦 dmg
✔️ a28bc08 #6 2019-04-11 23:48:32 ~17 min android 📦 apk
✔️ a28bc08 #6 2019-04-11 23:53:28 ~22 min linux 📦 App
✔️ a28bc08 #6 2019-04-11 23:54:09 ~22 min windows 📦 exe
✔️ a28bc08 #6 2019-04-11 23:55:45 ~24 min ios 📦 ipa
✔️ a28bc08 #6 2019-04-12 00:04:33 ~33 min android-e2e 📦 apk
0bdb37c #8 2019-04-12 16:23:49 ~3 min android-e2e 📄 log
✔️ 0bdb37c #8 2019-04-12 16:35:42 ~15 min macos 📦 dmg
✔️ 0bdb37c #8 2019-04-12 16:44:08 ~23 min android 📦 apk
✔️ 0bdb37c #8 2019-04-12 16:44:17 ~23 min windows 📦 exe
✔️ 0bdb37c #8 2019-04-12 16:45:36 ~25 min linux 📦 App
✔️ 0bdb37c #9 2019-04-12 16:58:20 ~18 min android-e2e 📦 apk

@mandrigin
Copy link
Contributor

@krisc thanks for your contribution! maybe @yenda or @flexsurfer can help you with the error function. But I would check if what is returned is similar to a URL, and show error otherwise.

env/dev/env/config.cljs Outdated Show resolved Hide resolved
@mandrigin
Copy link
Contributor

@krisc also, the formatting should be fixed (that's why CI builds are failing). I recommend running lein cljfmt fix to fix formatting.

@krisc
Copy link
Author

krisc commented Apr 3, 2019

@krisc also, the formatting should be fixed (that's why CI builds are failing). I recommend running lein cljfmt fix to fix formatting.

Oh, thanks! wasn't aware of that command. I get that error every time and didn't know why.

@krisc
Copy link
Author

krisc commented Apr 3, 2019

@krisc thanks for your contribution! maybe @yenda or @flexsurfer can help you with the error function. But I would check if what is returned is similar to a URL, and show error otherwise.

@yenda or @flexsurfer , is there a function somewhere in status that checks for vaild URLs? Perhaps someone could direct me to the code where URLs in chat messages are rendered as blue and underlined?

For now, I'm just checking if the string has a "." in it.

@krisc krisc changed the title WIP Scan url with QR scanner Scan url with QR scanner Apr 4, 2019
@krisc
Copy link
Author

krisc commented Apr 4, 2019

@mandrigin This should be it unless I should be error checking a different way. And FYI, the case where browser selection is canceled and then being able to scan another qr-code depends on code that came from this PR #7745

This PR pretty much has the aforementioned PR merged since it shares so much code. The other PR should probably be merged to upstream first.

@mandrigin
Copy link
Contributor

@krisc sounds good, then let's first land #7745 and then this one. I will take a look at the code today.

(fx/merge cofx
(navigation/navigate-to-clean :home {})
(process-qr-code data)))
(if (clojure.string/includes? data ".")
Copy link
Contributor

@mandrigin mandrigin Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use something like that to check for URLs:

(defn is-url [url] 
  (try 
    (and (js/URL. url) true) 
  (catch js/Error e false)))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this seems to always return true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I tried it in a repl and for me it returns false for, say, “aaa” and true for “http://google.com"...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I'm using figwheel for status-im, and returns true for anything. I did try in a web repl, and it does return false for something like "aaa". which repl did you use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be handled the same way a URL is handled when tapped on by a user in chat so I would like to see where in the code that renders a chat message as a link. for example, if a message contains "aaaa google.com" then the 'google.com' becomes underlined. I'm having trouble trying to find where this happens :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yenda maybe you know?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a regx-url in constants.cljs to check for urls

Copy link
Contributor

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition needs to be changed, I think, looks good otherwise!

@krisc
Copy link
Author

krisc commented Apr 10, 2019

@mandrigin @yenda I ended up using extensions/valid-uri? but was not yet able to test it because I'm having issues with make shell

Copy link
Contributor

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's good enough for now.

@mandrigin mandrigin requested review from jeluard and rasom April 11, 2019 07:20
@krisc
Copy link
Author

krisc commented Apr 11, 2019

Derp, I should have read the code https://github.com/status-im/status-react/blob/64b63d5593cebd7382b6894a71848589f9628e67/src/status_im/extensions/core.cljs#L865

It will always return false unless it's a status extension.

I think this should be handled the same way a URL is handled when tapped on by a user in chat so I would like to see where in the code that renders a chat message as a link. for example, if a message contains "aaaa google.com" then the 'google.com' becomes underlined. I'm having trouble trying to find where this happens :/

If someone could point me to where this happens, that would be great!

@yenda
Copy link
Contributor

yenda commented Apr 11, 2019

@krisc this is done in status-im.chat.models.message-content, the message string is parsed and urls are replaced by [:link "the url"], to find urls the regexp used is in constants/regex-url

@krisc
Copy link
Author

krisc commented Apr 11, 2019

@krisc this is done in status-im.chat.models.message-content, the message string is parsed and urls are replaced by [:link "the url"], to find urls the regexp used is in constants/regex-url

Exactly what I was looking for. Thanks!

@krisc
Copy link
Author

krisc commented Apr 11, 2019

Ok, this should be it!

Copy link
Contributor

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few tiny changes, looks good otherwise!

src/status_im/chat/models/message_content.cljs Outdated Show resolved Hide resolved
src/status_im/chat/models/message_content.cljs Outdated Show resolved Hide resolved
Copy link
Contributor

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now! just don't forget to squash the commits ;-)

@krisc
Copy link
Author

krisc commented Apr 12, 2019

@mandrigin not sure why it's saying "jenkins/prs/android-e2e — This commit cannot be built". I ran lein cljfmt fix before committing

@mandrigin
Copy link
Contributor

@krisc looks like a random thing, restarted it

@krisc
Copy link
Author

krisc commented Apr 12, 2019

@mandrigin BTW is there a way I can get access to the jenkins build logs? When I click on "Details" is says Access Denied krisc is missing the Overall/Read permission

@mandrigin
Copy link
Contributor

@krisc I think the access is limited until we audit our build logs for sensitive info... We will get there, it isn't just done yet.

@churik churik self-assigned this Apr 16, 2019
@churik
Copy link
Member

churik commented Apr 16, 2019

@krisc

1) Part of header is not white (Android)

dsfdfsdfdsfdf

2) After opening URL in native browser can't scan valid URL

Steps:

  • tap on +
  • scan QR code that contains link
  • tap on open on IOS (or Android)
  • go back to Status
  • try to scan same QR with link
    Expected result: can scan QR
    Actual result: QR is not recognizable again

3) Several times I saw crash on Android after scanning valid QR

Unfortunately didn't notice any specific steps to reproduce, during testing I scanned ~30 times different URLs and three times I saw this error anter tapping on "Open to Status" when scanning QR with link. Logcat:
crashlog.log

photo_2019-04-16 12 12 07

4) Ethereum address is considered as a valid link.

I didn't expect that wallet address can be scanned with "Scan QR code" in chat.
In this case I would prefer to see error.
Example of QR:
photo_2019-04-16 12 14 49

@krisc
Copy link
Author

krisc commented Apr 16, 2019

@churik thanks for uncovering these issues. I'll have more time to look into them next week.

@krisc
Copy link
Author

krisc commented May 3, 2019

Sorry, I've been busy with Ethereal Hackathon these past few weeks. I'll have more time to get back on this after the weekend.

But these issues may be related to some code I wrote for this issue #7745 (comment)

@status-github-bot
Copy link

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?

@flexsurfer
Copy link
Member

flexsurfer commented May 24, 2019

hey @krisc any updates on this? :)

@krisc
Copy link
Author

krisc commented May 24, 2019

hey @krisc any updates on this? :)

I was gonna try to resolve issues with #7745 (comment) because it might be related to the issues here.

Sorry I'm taking so long. I've been have some issues building and running since we switched to nix. So testing has been really slow for me.

@krisc
Copy link
Author

krisc commented Jun 5, 2019

I think I got my nix issues taken care of, but the easiest thing for me to move forward with this issue is to start a new PR. hope that's okay.

@flexsurfer
Copy link
Member

yeah that's fine, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants