Skip to content
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

Update master #574

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified client/public/assets/chewie.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions server/src/controllers/settingsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BotSettingsService, { BotSettings } from "../services/botSettingsService"
class SettingsController {
private readonly SettingDescriptions = {
[BotSettings.DonationPointsPerDollar]: { title: "Donations: Points added per USD", readonly: false },
[BotSettings.GoldStatusDonationAmount]: { title: "VIP Gold: USD required per month", readonly: false },
[BotSettings.GoldStatusDonationAmount]: { title: "VIP Gold: USD required for 4 weeks / requests", readonly: false },
[BotSettings.PointsPerBit]: { title: "Bits: Points added per Bit", readonly: false },
[BotSettings.PruneLogsAfterDays]: { title: "Amount of days to retain logs", readonly: false },
[BotSettings.RedeemCost]: { title: "Cost for !redeem command", readonly: false },
Expand All @@ -30,7 +30,7 @@ class SettingsController {
[BotSettings.SongDonationLink]: { title: "URL for donations on song queue page", readonly: false },
[BotSettings.CardsRequiredForUpgrade]: { title: "Number of cards required for redeeming an upgrade", readonly: false },
[BotSettings.CommandCooldownInSeconds]: { title: "Cooldown for regular text commands (in seconds)", readonly: false },
[BotSettings.GoldWeeksPerT3Sub]: { title: "Amount of VIP gold weeks per T3 sub", readonly: false },
[BotSettings.GoldWeeksPerT3Sub]: { title: "VIP Gold: Amount of weeks / requests per T3 sub", readonly: false },
[BotSettings.ReadonlyMode]: { title: "Read-only mode for points", readonly: false },
[BotSettings.MaxSongRequestRedemptionsInQueue]: { title: "Maximum number of song requests through channel rewards in queue", readonly: false },
[BotSettings.SubNotificationProvider]: { title: "Provider for subscription notifications (Twitch|Streamlabs)", readonly: false },
Expand All @@ -48,8 +48,8 @@ class SettingsController {
[BotSettings.TaxInspectorExemptUsers]: { title: "Users exempt from tax inspector", readonly: false },
[BotSettings.TaxEvasionPenaltyLeaderboardCount]: { title: "Number of top users from tax evasion leaderboard for penalty", readonly: false },
[BotSettings.TaxEvasionCooldown]: { title: "Number of minutes that tax evaders are safe after penalty", readonly: false },
[BotSettings.GoldStatusRequestLimit]: { title: "Limit VIP gold requests by 1 per week or stream (Week|Stream)", readonly: false },
[BotSettings.GoldStatusPermanentRequests]: { title: "Grant permanent VIP gold requests for donations", readonly: false },
[BotSettings.GoldStatusRequestLimit]: { title: "VIP Gold: Limit requests to 1 per week or stream (Week|Stream)", readonly: false },
[BotSettings.GoldStatusPermanentRequests]: { title: "VIP Gold: Use permanent requests instead of time periods", readonly: false },
};

constructor(
Expand Down
14 changes: 12 additions & 2 deletions server/src/services/rewardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ export default class RewardService {

if (sub.sub_plan === SubscriptionPlan.Tier3) {
const goldWeeksT3 = parseInt(await this.settings.getValue(BotSettings.GoldWeeksPerT3Sub), 10);
await this.userService.addVipGoldWeeks(user, goldWeeksT3, "T3 Resub");
const usePermanentRequests = await this.settings.getBoolValue(BotSettings.GoldStatusPermanentRequests);
if (usePermanentRequests) {
await this.userService.addPermanentVip(user, goldWeeksT3, "T3 Resub");
} else {
await this.userService.addVipGoldWeeks(user, goldWeeksT3, "T3 Resub");
}
}
}

Expand All @@ -104,7 +109,12 @@ export default class RewardService {
// Both gifter and receiver gets half the amount of VIP gold.
// We assume that the user on the receiving end will be covered by a streamlabs event.
if (giftingUser) {
await this.userService.addVipGoldWeeks(giftingUser, giftedMonths, "Gifted T3 sub");
const usePermanentRequests = await this.settings.getBoolValue(BotSettings.GoldStatusPermanentRequests);
if (usePermanentRequests) {
await this.userService.addPermanentVip(giftingUser, giftedMonths, "Gifted T3 sub");
} else {
await this.userService.addVipGoldWeeks(giftingUser, giftedMonths, "Gifted T3 sub");
}
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions server/src/services/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Logger, LogType } from "../logger";
import PointLogsRepository from "../database/pointLogsRepository";
import EventAggregator from "./eventAggregator";
import WebsocketService from "../services/websocketService";
import BotSettingsService, { BotSettings } from "../services/botSettingsService";

@injectable()
export class UserService {
Expand All @@ -17,7 +18,8 @@ export class UserService {
@inject(EventLogService) private eventLog: EventLogService,
@inject(EventAggregator) private eventAggregator: EventAggregator,
@inject(WebsocketService) private websocketService: WebsocketService,
@inject(PointLogsRepository) private pointsLog: PointLogsRepository) {
@inject(PointLogsRepository) private pointsLog: PointLogsRepository,
@inject(BotSettingsService) private settings: BotSettingsService) {
// Empty
}

Expand Down Expand Up @@ -179,7 +181,15 @@ export class UserService {
*/
public async addPermanentVip(user: IUser, amount: number, reason: string) {
user.vipPermanentRequests = user.vipPermanentRequests ? (user.vipPermanentRequests + amount) : amount;
await this.addVipGoldWeeks(user, amount, reason);

const usePermanentRequests = await this.settings.getBoolValue(BotSettings.GoldStatusPermanentRequests);
if (usePermanentRequests) {
// Not changing VIP expiry date here to limit available requests to the permanent ones
await this.users.updateVipExpiry(user);
await this.eventLog.addVipGoldAdded(user, { weeksAdded: 0, newExpiry: user.vipExpiry, permanentRequests: user.vipPermanentRequests, reason });
} else {
await this.addVipGoldWeeks(user, amount, reason);
}
}

/**
Expand Down