Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot commented Apr 11, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from barackvn April 11, 2023 04:30
Comment thread controllers/main.py
Comment on lines -14 to +18
appln_id = request.env['onesignal.credentials'].sudo().search([('is_active','=',True)])
if appln_id:
if (
appln_id := request.env['onesignal.credentials']
.sudo()
.search([('is_active', '=', True)])
):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function ActiveAppCtrl.check_active_app refactored with the following changes:

#STEP 1 : CHECK IF BOOLEAN ACTIVE IN OTHER APP
app_ids = self.search([('is_active','=',True)])
if app_ids:
if app_ids := self.search([('is_active', '=', True)]):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function OnesignalCredentials.activate_app refactored with the following changes:

This removes the following comments ( why? ):

#STEP 1 : CHECK IF BOOLEAN ACTIVE IN OTHER APP

Comment on lines -41 to +44
header = {"Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic {}".format(app.apikey)}
header = {
"Content-Type": "application/json; charset=utf-8",
"Authorization": f"Basic {app.apikey}",
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function OnesignalMessage.get_app_data refactored with the following changes:

Comment on lines -60 to +83

payload = {"app_id": "{}".format(appln_data.get('app_id')),
"included_segments": ["All"],
"contents": {"en": "{}".format(message_content)},
"headings" :{"en": "{}".format(message_title)},
"url": "{}".format(self.launch_url),
"chrome_web_icon": "{}".format(self.icon),
"ttl": self.time_to_live or 3,
}

payload = {
"app_id": f"{appln_data.get('app_id')}",
"included_segments": ["All"],
"contents": {"en": f"{message_content}"},
"headings": {"en": f"{message_title}"},
"url": f"{self.launch_url}",
"chrome_web_icon": f"{self.icon}",
"ttl": self.time_to_live or 3,
}
if self.priority:
priority = self.get_key(var,self.priority)
payload.update({
'priority':priority
})
payload['priority'] = priority
if self.send_to_chrome or self.send_to_mozilla or self.send_to_edge:
payload.update({
'isAnyWeb': True
})
payload['isAnyWeb'] = True
try:
response = requests.post("https://onesignal.com/api/v1/notifications", headers=header, data=json.dumps(payload))
if response.status_code == 200:
resp = response.json()
self.summary = "RECEIPIENTS : {}".format(resp.get('recipients'))
self.summary = f"RECEIPIENTS : {resp.get('recipients')}"
else:
self.summary = "Error : {}".format(response.text)
self.summary = f"Error : {response.text}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function OnesignalMessage.send_push_notification refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants