Skip to content

Implement voice bans to API#411

Merged
jb3 merged 9 commits into
python-discord:masterfrom
ks129:voice-gate
Oct 10, 2020
Merged

Implement voice bans to API#411
jb3 merged 9 commits into
python-discord:masterfrom
ks129:voice-gate

Conversation

@ks129
Copy link
Copy Markdown
Contributor

@ks129 ks129 commented Oct 10, 2020

  • Allow voice_ban infraction type.
  • Include voice banned status to metricity endpoint for better performance + cover it with test.

@ks129 ks129 requested a review from a team as a code owner October 10, 2020 17:24
@ks129 ks129 requested review from Den4200 and dementati October 10, 2020 17:24
@ghost ghost added the needs 2 approvals label Oct 10, 2020
Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

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

Looking good ks!

This work fine locally, I've inserted a record and queried the endpoint, it returns the expected result.

I've added a slight comment because I think the error handling section in the viewset is handling for an impossible case.

Comment thread pydis_site/apps/api/models/bot/infraction.py Outdated
Infraction.objects.get(user__id=user.id, active=True, type="voice_ban")
except ObjectDoesNotExist:
voice_banned = False
except MultipleObjectsReturned:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will there ever be multiple active voice bans for a user?

These cannot be in the DB due to the one active infraction type per user constraint.

ERROR:  duplicate key value violates unique constraint "unique_active_infraction_per_type_per_user"

@ghost ghost added s: waiting for author Waiting for author to address a review or respond to a comment and removed needs 2 approvals labels Oct 10, 2020
Copy link
Copy Markdown
Contributor

@scragly scragly left a comment

Choose a reason for hiding this comment

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

Everything looks great to me, just a tiny suggested change that isn't your fault at all.

Comment thread pydis_site/apps/api/models/bot/infraction.py Outdated
Co-authored-by: Joe Banks <joseph@josephbanks.me>
@ghost ghost added needs 2 approvals and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Oct 10, 2020
@ks129 ks129 requested review from jb3 and scragly October 10, 2020 17:36
Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

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

Great stuff!

@ghost ghost removed the needs 1 approval label Oct 10, 2020
@jb3 jb3 merged commit 071ef50 into python-discord:master Oct 10, 2020
@ks129 ks129 deleted the voice-gate branch October 10, 2020 17:44
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.

3 participants