Skip to content

CON-328 Add HTTP call to the slack when a meeting is ended#505

Open
Ramadhan0 wants to merge 2 commits intodevelopfrom
story/CON-328-HTTP-call-to-the-slack
Open

CON-328 Add HTTP call to the slack when a meeting is ended#505
Ramadhan0 wants to merge 2 commits intodevelopfrom
story/CON-328-HTTP-call-to-the-slack

Conversation

@Ramadhan0
Copy link
Contributor

@Ramadhan0 Ramadhan0 commented Oct 11, 2019

Description

This feature ensures that an HTTP call is made to the slack integration micro-service when a meeting is ended, either by the user or when the meeting time runs out.

It sends out different arguments including the organizer_email, room_id, and the event_id.

How to test it:

  • update your .env file with this variable
    SLACK_NOTIFICATION_URL=https://www.softwaretestinghelp.com/tools/30-top-website-link-verification-testing-tools/
  • make sure all services are up including redis
  • open insomnia or postman and hit the end event mutation structured as below,
    mutation{ endEvent(calendarId:"andela.com_38393338303730373538@resource.calendar.google.com", eventId:"0manph5i3e8lnld6tnvb0o1pcc", organizerEmail:"converge.notification@andela.com", roomId: "18", startTime:"2018-08-19T23:00:00-07:00", endTime:"2018-08-20T05:00:00-07:00", meetingEndTime: "2018-08-14T07:00:00-07:00"){ event{ eventId eventTitle checkedIn cancelled meetingEndTime room{ id name calendarId } } } }
  • check-in the celery.err.log file for the response to be 200 after finishing the task with a notify-slack name.

Type of change

Please select the relevant option

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Others (cosmetics, styling, improvements)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit
  • Integration
  • End-to-end

New feature

JIRA

CON-328
CV3-63

@Ramadhan0 Ramadhan0 added the wip label Oct 11, 2019
@Ramadhan0 Ramadhan0 force-pushed the story/CON-328-HTTP-call-to-the-slack branch 28 times, most recently from 82fb602 to 775708d Compare October 15, 2019 16:53
@Ramadhan0 Ramadhan0 force-pushed the story/CON-328-HTTP-call-to-the-slack branch 6 times, most recently from f22261b to b936f9b Compare October 16, 2019 12:11
Copy link

@MCFrank16 MCFrank16 left a comment

Choose a reason for hiding this comment

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

Good job @Ramadhan0

@@ -0,0 +1,12 @@
import requests
import os

Choose a reason for hiding this comment

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

where will you use this os on?

@MCFrank16 MCFrank16 self-requested a review October 17, 2019 06:32
@Ramadhan0 Ramadhan0 force-pushed the story/CON-328-HTTP-call-to-the-slack branch from b936f9b to 5981a90 Compare October 17, 2019 07:09
mifeille
mifeille previously approved these changes Oct 17, 2019
Copy link
Contributor

@joshuaocero joshuaocero left a comment

Choose a reason for hiding this comment

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

@Ramadhan0 there are a couple of things you need to work on. Please look into my feedback.

config.py Outdated
CELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND')

# slack bot url
notify_url = os.getenv('SLACK_NOTIFICATION_URL')
Copy link
Contributor

Choose a reason for hiding this comment

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

Please maintain consistency in variable naming. As you can see, all the other config variables are uppercased.

"""

@celery.task(name="notify-slack")
def notify(event_Id):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)


@celery.task(name="notify-slack")
def notify(event_Id):
requests.get(url=Config.notify_url+str(event_Id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you casting event_Id to a string. Is it necessary? Also, please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the event_id is an integer and the URL is a string
so, without converting event_id to a string was causing an error @joshuaocero

event_reject_reason
):
raise GraphQLError("Event cancelled but email not sent")
event_Id=kwargs['event_id']
Copy link
Contributor

Choose a reason for hiding this comment

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

Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)

):
raise GraphQLError("Event cancelled but email not sent")
event_Id=kwargs['event_id']
notify.delay(event_Id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)

@@ -0,0 +1,11 @@
import requests
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this filename leaner. It is already in a folder called events, no need to prefix the filename with event_.

"""

@celery.task(name="notify-slack")
def notify(event_Id):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this function name more descriptive. notify what? Think of a better function name. Ask yourself what exactly the function is doing then name it appropriately.

class test_slack_notifier(unittest.TestCase):

@patch('helpers.event.event_slack_notifier.requests.get')
def test_add_room(self, mock_get_request):
Copy link
Contributor

@joshuaocero joshuaocero Oct 21, 2019

Choose a reason for hiding this comment

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

Why is this function called test_add_room? You need to pay more attention to detail. Avoid unnecessary copying and pasting.

@Ramadhan0 Ramadhan0 force-pushed the story/CON-328-HTTP-call-to-the-slack branch 5 times, most recently from 6e54f6f to c8db89e Compare October 22, 2019 14:40

def upgrade():
op.add_column('events', sa.Column(
'organizer_email', sa.String(), nullable=True))
Copy link
Contributor

Choose a reason for hiding this comment

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

I just checked Samuel's PR and I saw that the organizer email is sent as a list since it is taking two emails, is this data type appropriate for storing it?

Choose a reason for hiding this comment

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

I just wanna know from the list of 2 emails, how will I know which one is the actual organizer_email @mifeille

Copy link
Contributor

@mifeille mifeille left a comment

Choose a reason for hiding this comment

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

Please validate organizerEmail and roomId fields.

Ramadhan0 and others added 2 commits December 10, 2019 10:32
  - ensure the returned url is comprised with the organizer_email and room_id

[Delivers CON-328]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TTL Review Technical Team Lead Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants