-
Notifications
You must be signed in to change notification settings - Fork 203
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
Fix #1594 Alexa webhook for priority label #1615
Conversation
32c1965
to
e9a54d6
Compare
r? = @karlcow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MDTsai a couple of changes here and there. Hope it helps.
tests/test_webhook.py
Outdated
"""Extract priority label.""" | ||
with patch('webcompat.db.site_db.query') as db_mock: | ||
db_mock.return_value.filter_by.return_value = | ||
[Site('google.com', 1, '', 1)] |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
tests/test_webhook.py
Outdated
from webcompat import app | ||
from webcompat.db import Site | ||
from webcompat.webhooks import helpers | ||
|
||
# Add webcompat module to import path |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/db/__init__.py
Outdated
@@ -9,6 +9,7 @@ | |||
from sqlalchemy.ext.declarative import declarative_base | |||
from sqlalchemy import Column | |||
from sqlalchemy import String | |||
from sqlalchemy import Integer | |||
from sqlalchemy.orm import scoped_session | |||
from sqlalchemy.orm import sessionmaker | |||
from hashlib import sha512 |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/db/__init__.py
Outdated
site_db = scoped_session(sessionmaker(autocommit=False, | ||
autoflush=False, | ||
bind=site_engine)) | ||
|
||
|
||
class WCIssue(IssueBase): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/webhooks/helpers.py
Outdated
@@ -78,3 +82,25 @@ def get_payload_signature(key, payload): | |||
'''Compute the payload signature given a key.''' | |||
mac = hmac.new(key, msg=payload, digestmod=hashlib.sha1) | |||
return mac.hexdigest() | |||
|
|||
|
|||
def extract_priority_label(body): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/webhooks/helpers.py
Outdated
for i in list(reversed(range(2, len(domains)))): | ||
shorten_domain_name = '.'.join(domains[(len(domains)-i):]) | ||
for site in site_db.query(Site).filter_by(url=shorten_domain_name): | ||
return 'priority-{}'.format(priorities[site.priority-1]) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Addd alexa topsite DB Find priority label for domain name or less-level domain in DB
Adding do not merge label until we have Alexa API credentials in place. |
Addd alexa topsite DB
Find priority label for domain name or less-level domain in DB