Skip to content

Commit

Permalink
raffles: implement shadow ban on raffles
Browse files Browse the repository at this point in the history
  • Loading branch information
GGonryun committed Sep 29, 2024
1 parent 05289c8 commit 4656878
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
17 changes: 13 additions & 4 deletions libs/services/raffles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ export class RafflesService {
}

async processExpiredRaffle(raffle: ExpiredRaffle) {
if (raffle.participants.length === 0) {
// shadow-ban users with multiplier < 0.5
const participants = raffle.participants.filter(
(p) => p.user.multiplier > 0.5
);

console.log(
`All participants ${raffle.participants.length}, viable participants ${participants.length}`
);

if (participants.length === 0) {
console.info('No participants in raffle', raffle.id);
await this.#db.raffle.update({
where: {
Expand All @@ -125,7 +134,7 @@ export class RafflesService {
};
}

if (!raffle.participants.every((p) => p.numEntries >= 0)) {
if (!participants.every((p) => p.numEntries >= 0)) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message:
Expand All @@ -142,7 +151,7 @@ export class RafflesService {
},
});

const winners = pickWinners(raffle.numWinners, raffle.participants);
const winners = pickWinners(raffle.numWinners, participants);

console.info('Winners:', winners.map((w) => w.user.email).join(', '));

Expand All @@ -163,7 +172,7 @@ export class RafflesService {
);
}

const losers = raffle.participants.filter(
const losers = participants.filter(
(p) => !winners.some((w) => w.participationId === p.id)
);

Expand Down
1 change: 1 addition & 0 deletions libs/services/raffles/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const EXPIRED_RAFFLE_PROPS = {
select: {
id: true,
email: true,
multiplier: true,
},
},
id: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We do not knowingly collect personally identifiable information from anyone unde
You agree to use this site only for lawful purposes:
<br/>
<br/>
(a) Specifically you do not use this site for any of the following purposes which are expressly prohibited: (1) upload any content that is unlawful, harmful, threatening, abusive, harassing, tortious, defamatory, vulgar, obscene, libelous, invasive of another's privacy, hateful, or racially, ethnically or otherwise objectionable; (2) use this site to violate the legal rights including the rights of privacy of others or to violate laws of any jurisdiction; (3) intercept or attempt to intercept electronic mail that is not intended for you; (4) misrepresent an affiliation with any person; (5) upload or transmit any files containing viruses or other harmful computer code; (6) upload, transmit or otherwise make available any material that contains software or other material protected by intellectual property laws, rights of privacy or publicity or any other applicable law. (7) transmit or upload any material that contains viruses, trojan horses, worms, time bombs, cancelbots, or any other harmful or deleterious programs; (8) interfere with or disrupt the site or networks connected to the site, or disobey any requirements, procedures, policies or regulations of networks connected to the site; (9) engage in any other conduct that restricts or inhibits anyone's use or enjoyment of the Charity Games website, or which, as determined by Charity Games, may harm us or our visitors or expose them to liability; (10) impersonate any person or entity, including, but not limited to, a Charity Games official, forum leader, guide or host, or falsely state or otherwise misrepresent your affiliation with a person or entity; (11) forge headers or otherwise manipulate identifiers in order to disguise the origin of any content transmitted through the site; (12) upload, post, email, transmit or otherwise make available any unsolicited or unauthorized advertising, promotional materials, "junk mail," "spam," "chain letters," "pyramid schemes," or any other form of solicitation; (13) disrupt the normal flow of dialogue, cause a screen to "scroll" faster than other users of the site are able to type, or otherwise act in a manner that negatively affects other users' ability to engage in real time exchanges; (14) interfere with or disrupt the site or servers or networks connected to the site, or disobey any requirements, procedures, policies or regulations of networks connected to the site; (15) "stalk" or otherwise harass another; or (16) collect or store personal data about other users. Without limiting any of the foregoing, (17) use any automated system, including but not limited to bots, scripts, or other non-human activities, to interact with the site. (18) You also agree to abide by any code of conduct and policies applicable to the Charity Games website or any service available on our website.
(a) Specifically you do not use this site for any of the following purposes which are expressly prohibited: (1) upload any content that is unlawful, harmful, threatening, abusive, harassing, tortious, defamatory, vulgar, obscene, libelous, invasive of another's privacy, hateful, or racially, ethnically or otherwise objectionable; (2) use this site to violate the legal rights including the rights of privacy of others or to violate laws of any jurisdiction; (3) intercept or attempt to intercept electronic mail that is not intended for you; (4) misrepresent an affiliation with any person; (5) upload or transmit any files containing viruses or other harmful computer code; (6) upload, transmit or otherwise make available any material that contains software or other material protected by intellectual property laws, rights of privacy or publicity or any other applicable law. (7) transmit or upload any material that contains viruses, trojan horses, worms, time bombs, cancelbots, or any other harmful or deleterious programs; (8) interfere with or disrupt the site or networks connected to the site, or disobey any requirements, procedures, policies or regulations of networks connected to the site; (9) engage in any other conduct that restricts or inhibits anyone's use or enjoyment of the Charity Games website, or which, as determined by Charity Games, may harm us or our visitors or expose them to liability; (10) impersonate any person or entity, including, but not limited to, a Charity Games official, forum leader, guide or host, or falsely state or otherwise misrepresent your affiliation with a person or entity; (11) forge headers or otherwise manipulate identifiers in order to disguise the origin of any content transmitted through the site; (12) upload, post, email, transmit or otherwise make available any unsolicited or unauthorized advertising, promotional materials, "junk mail," "spam," "chain letters," "pyramid schemes," or any other form of solicitation; (13) disrupt the normal flow of dialogue, cause a screen to "scroll" faster than other users of the site are able to type, or otherwise act in a manner that negatively affects other users' ability to engage in real time exchanges; (14) interfere with or disrupt the site or servers or networks connected to the site, or disobey any requirements, procedures, policies or regulations of networks connected to the site; (15) "stalk" or otherwise harass another; or (16) collect or store personal data about other users. Without limiting any of the foregoing, (17) use any automated system, including but not limited to bots, scripts, or other non-human activities, to interact with the site. (18) Members are only allowed to have one account per person. (19) You also agree to abide by any code of conduct and policies applicable to the Charity Games website or any service available on our website.
<br/>
<br/>
All content and/or opinions uploaded, expressed or submitted to a message board, blog, chatroom or any other publicly available section of the Charity Games website (including password-protected areas), and all articles and responses to questions, other than the content provided by Charity Games, are solely the opinions and responsibility of the person or entity submitting them and do not necessarily reflect the opinions of Charity Games. Charity Games is not responsible for content that third parties publish, post, upload, distribute, disseminate or otherwise transmit via the Charity Games website. Charity Games does not and cannot review all content posted to the Charity Games website by users and is not responsible for such content. However, Charity Games reserves the right to refuse to post and the right to remove any content, in whole or in part, for any reason or for no reason. You are responsible for whatever content you submit, and you, not Charity Games, have full responsibility for such content, including its legality, reliability and appropriateness.
Expand Down

0 comments on commit 4656878

Please sign in to comment.