#191 Send username of recipient to Fedora Bus
Closed: complete 4 years ago by jflory7. Opened 5 years ago by shraddhaag.

Summary

Send username of recipient to Fedora Bus

Background

Currently the name of the recipient is being sent to the Fedora Bus. We need to send the username of the recipient instead so that a badge can be awarded to the recipient.

Details

Ticket #127 will automatically result in solving this.

Outcome

The username of the recipient is being sent to the Bus.


Metadata Update from @jflory7:
- Issue marked as depending on: #127
- Issue priority set to: waiting on external (was: awaiting triage)
- Issue tagged with: PASSED, blocked, improvement, type - backend, type - fedora-messaging, type - summer coding

5 years ago

Metadata Update from @jflory7:
- Issue marked as depending on: #198

5 years ago

I just checked the way #127 is solved and realised that it doesn't solve this issue as it populates the recipient's name with their full name not username.
The solution to this could be:
1. Using people_query function of python-fedora to get the username from the email if the sender has given the receiver's email address set in the Fedora Account System.
2. If Fedora Project email alias is used, we can get the username from the email itself.
@jflory7 I'd like to work on this :)

Hi @shraddhaag! I think there was a quick discussion about this in another ticket too, but I can't find it now…

The solution to this could be:
1. Using people_query function of python-fedora to get the username from the email if the sender has given the receiver's email address set in the Fedora Account System.
2. If Fedora Project email alias is used, we can get the username from the email itself.

I thought one low-cost way of doing this look-up is to add some sort of method to check if a FAS username search (from #196) is successful or not (i.e. is a user with the specified username found?). If yes, we could save the string from the user input text box since the user already gave us the username, and then we don't have to do another look-up.

If FAS username search is not used, we should run a check on the provided email to see if either it matches the email in someone's FAS account or if it is their @fedoraproject.org alias.

The flaw in this idea is we don't have a good way of telling whether someone chose to do a FAS username look-up or if they manually entered name/email.

@jflory7 I'd like to work on this :)

Sure! Let's discuss more, but I will assign this one to you. :thumbsup:

Metadata Update from @jflory7:
- Issue unmarked as depending on: #198
- Issue untagged with: blocked
- Issue assigned to shraddhaag
- Issue priority set to: waiting on assignee (was: waiting on external)

5 years ago

I just checked the way #127 is solved and realised that it doesn't solve this issue as it populates the recipient's name with their full name not username.
The solution to this could be:
1. Using people_query function of python-fedora to get the username from the email if the sender has given the receiver's email address set in the Fedora Account System.
2. If Fedora Project email alias is used, we can get the username from the email itself.
@jflory7 I'd like to work on this :)

Hey @shraddhaag ! Were you able to retrieve the username from the email address using python-fedora ?

Hi @shraddhaag! I think there was a quick discussion about this in another ticket too, but I can't find it now…

Hi @jflory7! The discussion started in PR #161 description and further continued in the comments here to the best of my knowledge.

I thought one low-cost way of doing this look-up is to add some sort of method to check if a FAS username search (from #196) is successful or not (i.e. is a user with the specified username found?). If yes, we could save the string from the user input text box since the user already gave us the username, and then we don't have to do another look-up.
If FAS username search is not used, we should run a check on the provided email to see if either it matches the email in someone's FAS account or if it is their @fedoraproject.org alias.
The flaw in this idea is we don't have a good way of telling whether someone chose to do a FAS username look-up or if they manually entered name/email.

I was able to incorporate this using sessions. I put a flag variable when the FAS username search is successful to determine whether FAS search was used. But this method fails at two instances:

  1. The user can open the confirmation email on other devices/different browser windows which will lead to different sessions than where the FAS search was made. This will lead to incorrect results.
  2. After the FAS search is successful (here the flag variable is set to True) if the user chooses to change the email and/or name manually in the same form, the flag variable is still be set to True and this will again lead to incorrect results.

I'm searching on:

  1. How to send the username of the recipient between multiple views. As a solution, I could send the username of the recipient in a URL pattern which captures the username as a named keyword arguments. But I wasn't sure if that would be ideal and hence was looking into other ways to accomplish the same.

  2. How manual input and auto populated input is differentiated and identified in working systems.

If you could point me in the right direction that would be really helpful!

Hey @shraddhaag ! Were you able to retrieve the username from the email address using python-fedora ?

@alishapapun Yes I was able to get the username of the recipient from the email address using python-fedora. I have detailed the same in my previous comment, bullet 1. Cheers!

@alishapapun Yes I was able to get the username of the recipient from the email address using python-fedora. I have detailed the same in my previous comment, bullet 1. Cheers!

Could you be more specific of what are the arguments you passed to fetch the username from the email? For example, what would be the query if I want to find the username of abc@gmail.com ?

Could you be more specific of what are the arguments you passed to fetch the username from the email? For example, what would be the query if I want to find the username of abc@gmail.com ?

Sure. The query I used here is this:

from fedora.client.fas2 import AccountSystem
from fedora.client import AuthError

fas = AccountSystem(username='Your-FAS-username', password='Your-FAS-Password')

query = fas.people_query(constraints={'email':'abc@gmail.com'}, columns=['username'])

I used the people_query method. Here, the keyword argument constraints is used to specify the equivalent WHERE condition but in the form of a python dictionary. I used the kwarg columns to specify what columns I need in the response. Here is the screenshot of the query and the result.

QueryResultForUsernameUsingPythonFedora.png

Could you be more specific of what are the arguments you passed to fetch the username from the email? For example, what would be the query if I want to find the username of abc@gmail.com ?

Sure. The query I used here is this:
from fedora.client.fas2 import AccountSystem
from fedora.client import AuthError

fas = AccountSystem(username='Your-FAS-username', password='Your-FAS-Password')

query = fas.people_query(constraints={'email':'abc@gmail.com'}, columns=['username'])

I used the people_query method. Here, the keyword argument constraints is used to specify the equivalent WHERE condition but in the form of a python dictionary. I used the kwarg columns to specify what columns I need in the response. Here is the screenshot of the query and the result.
QueryResultForUsernameUsingPythonFedora.png

Thanks @shraddhaag . It works :)

I have successfully been able to implement this functionality in the low-cost way as suggested by @jflory7, using the method detailed below.

When a user searches using FAS username and it's successful, the username and email get saved in the current session. When the form is submitted, the recipient email send via form and the one that is saved in the session is compared and if found same, FAS search was used. If not, then either user altered after FAS search or didn't use it in the first place.

I have added an optional field in the Message Model to save the username of the recipient if the email is associated to a FAS account, called recipient_username. After the form is submit, this field is populated as follows:

  1. If the FAS username search was used (detailed above), then the field saves the FAS username saved in sessions.
  2. If not, if the recipient email has @fedoraproject.org then username is extracted from there and saved in the field.
  3. If not, a username lookup using python-fedora is done and if found the field is populated with that.

Finally, if even python-fedora doesn't return a username, then recipient email is not associated with any FAS account and the same is logged in the server.

Using this field, when the user confirms sending the packet, the username of the recipient is sent to Bus using fedora-messaging.

@jflory7 I've send a PR with the above changes incorporated. Please find the time to review :)

Metadata Update from @jflory7:
- Issue set to the milestone: Summer Coding 2019: community bonding

4 years ago

Thanks again for the PR @shraddhaag. :smile: I'm closing this ticket as complete by PR #219. :clapper:

Metadata Update from @jflory7:
- Issue close_status updated to: complete
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.