Skip to content

Commit

Permalink
feat(hosts): remove depreated hosts (#5444)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Sep 8, 2022
1 parent c70f375 commit 19b66ca
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 123 deletions.
2 changes: 1 addition & 1 deletion d.ts/eventlist.d.ts
@@ -1,6 +1,6 @@
declare namespace EventList {
export interface Event {
event: 'follow' | 'rewardredeem' | 'cheer' | 'subgift' | 'subcommunitygift' | 'resub' | 'sub' | 'raid' | 'host' | 'tip';
event: 'follow' | 'rewardredeem' | 'cheer' | 'subgift' | 'subcommunitygift' | 'resub' | 'sub' | 'raid' | 'tip';
timestamp: number;
userId: string;
fromId?: string;
Expand Down
8 changes: 1 addition & 7 deletions locales/en.json
Expand Up @@ -308,7 +308,6 @@
},
"eventlist-events": {
"follow": "<strong>Followed</strong> you",
"host": "<strong>Hosted</strong> you with <strong>$viewers</strong> viewers.",
"raid": "<strong>Raided</strong> you with <strong>$viewers</strong> raiders.",
"sub": "<strong>Subscribed</strong> to you with <strong>$subType</strong>. They've been subscribed for $subCumulativeMonths $subCumulativeMonthsName.",
"subgift": "has been <strong>gifted</strong> subscription from <strong>$username</strong>",
Expand Down Expand Up @@ -353,7 +352,7 @@
"game": "Current category",
"language": "Current stream language",
"viewers": "Current viewers count",
"hostViewers": "Host/Raid viewers count",
"hostViewers": "Raid viewers count",
"followers": "Current followers count",
"subscribers": "Current subscribers count",
"arg": "Argument",
Expand Down Expand Up @@ -560,12 +559,9 @@
"events-reason-for-ban-timeout": "reason for ban/timeout",
"events-duration-of-timeout": "duration of timeout",
"events-duration-of-commercial": "duration of commercial",
"events-target-of-your-hosting": "target of your hosting",
"events-viewers-of-hosting": "viewers of hosting",
"overlays-eventlist-resub": "resub",
"overlays-eventlist-subgift": "subgift",
"overlays-eventlist-subcommunitygift": "subcommunitygift",
"overlays-eventlist-host": "host",
"overlays-eventlist-sub": "sub",
"overlays-eventlist-follow": "follow",
"overlays-eventlist-cheer": "bits",
Expand Down Expand Up @@ -764,8 +760,6 @@
"clearchat": "chat was cleared",
"action": "user sent /me",
"ban": "user was banned",
"hosting": "your channel started hosting",
"hosted": "your channel is hosted",
"raid": "your channel is raided",
"mod": "user is a new mod",
"timeout": "user was timeouted",
Expand Down
2 changes: 0 additions & 2 deletions locales/en/ui/overlays/credits.json
Expand Up @@ -4,7 +4,6 @@
"cCreditsAggregated": "Aggregated credits",
"cShowGameThumbnail": "Show game thumbnail",
"cShowFollowers": "Show followers",
"cShowHosts": "Show hosts",
"cShowRaids": "Show raids",
"cShowSubscribers": "Show subscribers",
"cShowSubgifts": "Show gifted subs",
Expand All @@ -17,7 +16,6 @@
"cTextLastSubMessage": "Last submessge",
"cTextStreamBy": "Streamed by",
"cTextFollow": "Follow by",
"cTextHost": "Hosted by",
"cTextRaid": "Raided by",
"cTextCheer": "Cheer by",
"cTextSub": "Subscribe by",
Expand Down
1 change: 0 additions & 1 deletion locales/en/ui/registry/alerts.json
Expand Up @@ -52,7 +52,6 @@
"subgifts": "Subgifts",
"subcommunitygifts": "Subgifts to community",
"tips": "Tips",
"hosts": "Hosts",
"raids": "Raids",
"cmdredeems": "Custom",
"promo": "Promo",
Expand Down
2 changes: 0 additions & 2 deletions locales/en/ui/registry/plugins.json
Expand Up @@ -24,8 +24,6 @@
"twitchStreamStarted": "Twitch stream started",
"twitchStreamStopped": "Twitch stream stopped",
"twitchRaid": "Twitch raid incoming",
"twitchHosted": "Twitch host incoming",
"twitchHosting": "Twitch host outgoing",
"tip": "Tipped by user",
"botStarted": "Bot started"
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -11,10 +11,10 @@
"author": "Michal Orlik <sogehige@gmail.com>",
"license": "MIT",
"dependencies": {
"@sogebot/ui-admin": "^63.1.0",
"@sogebot/ui-admin": "^64.0.0",
"@sogebot/ui-helpers": "^3.1.0",
"@sogebot/ui-oauth": "~3.1.1",
"@sogebot/ui-overlay": "^32.0.0",
"@sogebot/ui-overlay": "^33.0.0",
"@sogebot/ui-public": "^4.0.0",
"@twurple/api": "^5.2.3",
"@twurple/auth": "^5.2.3",
Expand Down
22 changes: 0 additions & 22 deletions src/database/entity/alert.ts
Expand Up @@ -169,7 +169,6 @@ export interface AlertInterface {
subs: CommonSettingsInterface[];
subgifts: CommonSettingsInterface[];
subcommunitygifts: CommonSettingsInterface[];
hosts: CommonSettingsInterface[];
raids: CommonSettingsInterface[];
tips: AlertTipInterface[];
cheers: AlertTipInterface[];
Expand Down Expand Up @@ -316,12 +315,6 @@ export const Alert = new EntitySchema<Readonly<Required<AlertInterface>>>({
inverseSide: 'alert',
cascade: true,
},
hosts: {
type: 'one-to-many',
target: 'alert_host',
inverseSide: 'alert',
cascade: true,
},
raids: {
type: 'one-to-many',
target: 'alert_raid',
Expand Down Expand Up @@ -439,21 +432,6 @@ export const AlertSubgift = new EntitySchema<Readonly<Required<CommonSettingsInt
},
});

export const AlertHost = new EntitySchema<Readonly<Required<CommonSettingsInterface>>>({
name: 'alert_host',
columns: { ...CommonSettingsSchema },
relations: {
alert: {
type: 'many-to-one',
target: 'alert',
inverseSide: 'hosts',
joinColumn: { name: 'alertId' },
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
},
});

export const AlertRaid = new EntitySchema<Readonly<Required<CommonSettingsInterface>>>({
name: 'alert_raid',
columns: { ...CommonSettingsSchema },
Expand Down
2 changes: 0 additions & 2 deletions src/database/entity/overlay.ts
Expand Up @@ -206,7 +206,6 @@ export interface OverlayMapperCredits extends OverlayMapperInterfaceCommon {
lastSubMessage: string,
streamBy: string,
follow: string,
host: string,
raid: string,
cheer: string,
sub: string,
Expand All @@ -217,7 +216,6 @@ export interface OverlayMapperCredits extends OverlayMapperInterfaceCommon {
},
show: {
follow: boolean,
host: boolean,
raid: boolean,
sub: boolean,
subgift: boolean,
Expand Down
Expand Up @@ -8,7 +8,7 @@ export class addAlertParries1630924716945 implements MigrationInterface {
const alerts = {} as any;
for (const type of [
'follow', 'sub', 'subcommunitygift',
'subgift', 'host', 'raid', 'tip', 'cheer',
'subgift', 'raid', 'tip', 'cheer',
'resub', 'command_redeem', 'reward_redeem',
]) {
alerts[type] = await queryRunner.query(`SELECT * FROM alert_${type}`);
Expand All @@ -35,7 +35,7 @@ export class addAlertParries1630924716945 implements MigrationInterface {
// resave all alerts
for (const type of [
'follow', 'sub', 'subcommunitygift',
'subgift', 'host', 'raid', 'tip', 'cheer',
'subgift', 'raid', 'tip', 'cheer',
'resub', 'command_redeem', 'reward_redeem',
]) {
await queryRunner.manager.getRepository(`alert_${type}`).clear();
Expand Down
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class removeHostsTables1662119547478 implements MigrationInterface {
name = 'removeHostsTables1662119547478';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE \`alert_host\``);
}

public async down(queryRunner: QueryRunner): Promise<void> {
return;
}

}
Expand Up @@ -8,7 +8,7 @@ export class addAlertParries1630924716945 implements MigrationInterface {
const alerts = {} as any;
for (const type of [
'follow', 'sub', 'subcommunitygift',
'subgift', 'host', 'raid', 'tip', 'cheer',
'subgift', 'raid', 'tip', 'cheer',
'resub', 'command_redeem', 'reward_redeem',
]) {
alerts[type] = await queryRunner.query(`SELECT * FROM alert_${type}`);
Expand Down Expand Up @@ -36,7 +36,7 @@ export class addAlertParries1630924716945 implements MigrationInterface {
// resave all alerts
for (const type of [
'follow', 'sub', 'subcommunitygift',
'subgift', 'host', 'raid', 'tip', 'cheer',
'subgift', 'raid', 'tip', 'cheer',
'resub', 'command_redeem', 'reward_redeem',
]) {
await queryRunner.manager.getRepository(`alert_${type}`).clear();
Expand Down
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class removeHostsTables1662119547478 implements MigrationInterface {
name = 'removeHostsTables1662119547478';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "alert_host"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
return;
}

}
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class removeHostsTables1662119547478 implements MigrationInterface {
name = 'removeHostsTables1662119547478';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "alert_host"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
return;
}

}
12 changes: 0 additions & 12 deletions src/events.ts
Expand Up @@ -115,10 +115,6 @@ class Events extends Core {
{ id: 'clearchat' },
{ id: 'action', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner' ] },
{ id: 'ban', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'reason' ] },
{ id: 'hosting', variables: [ 'target', 'hostViewers' ] },
{
id: 'hosted', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'hostViewers' ], definitions: { viewersAtLeast: 1 }, check: this.checkHosted,
},
{
id: 'raid', variables: [ 'username', 'is.moderator', 'is.subscriber', 'is.vip', 'is.broadcaster', 'is.bot', 'is.owner', 'hostViewers' ], definitions: { viewersAtLeast: 1 }, check: this.checkRaid,
},
Expand Down Expand Up @@ -199,8 +195,6 @@ class Events extends Core {
'reward-redeemed',
'timeout',
'ban',
'hosting',
'hosted',
'raid',
'stream-started',
'stream-stopped',
Expand Down Expand Up @@ -529,12 +523,6 @@ class Events extends Core {
return shouldTrigger;
}

public async checkHosted(event: EventInterface, attributes: EventsEntity.Attributes) {
event.definitions.viewersAtLeast = Number(event.definitions.viewersAtLeast); // force Integer
const shouldTrigger = (attributes.hostViewers >= event.definitions.viewersAtLeast);
return shouldTrigger;
}

public async checkStreamIsRunningXMinutes(event: EventInterface) {
if (!isStreamOnline.value) {
return false;
Expand Down
7 changes: 1 addition & 6 deletions src/graphql/resolvers/alertResolver.ts
Expand Up @@ -11,7 +11,7 @@ import { v4 } from 'uuid';

import { AlertObject } from '../schema/alert/AlertObject';

const relations = ['promo', 'rewardredeems', 'cmdredeems', 'cheers', 'follows', 'hosts', 'raids', 'resubs', 'subcommunitygifts', 'subgifts', 'subs', 'tips'];
const relations = ['promo', 'rewardredeems', 'cmdredeems', 'cheers', 'follows', 'raids', 'resubs', 'subcommunitygifts', 'subgifts', 'subs', 'tips'];

@Resolver()
export class alertResolver {
Expand Down Expand Up @@ -83,11 +83,6 @@ export class alertResolver {
...o, id: v4(), imageId: o.imageId, soundId: o.soundId,
};
}),
hosts: item.hosts.map((o) => {
return {
...o, id: v4(), imageId: o.imageId, soundId: o.soundId,
};
}),
raids: item.raids.map((o) => {
return {
...o, id: v4(), imageId: o.imageId, soundId: o.soundId,
Expand Down
2 changes: 0 additions & 2 deletions src/graphql/schema/alert/AlertObject.ts
Expand Up @@ -45,8 +45,6 @@ export class AlertObject implements AlertInterface {
subgifts: CommonSettingsObject[];
@Field(type => [CommonSettingsObject])
subcommunitygifts: CommonSettingsObject[];
@Field(type => [CommonSettingsObject])
hosts: CommonSettingsObject[];
@Field(type => [CommonSettingsObject])
raids: CommonSettingsObject[];
@Field(type => [AlertTipObject])
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/events/emitter.ts
Expand Up @@ -59,8 +59,6 @@ interface Events {
'reward-redeemed': (opts: {userId: string; userName: string; rewardId: string; userInput: string;}) => void;
'timeout': (opts: {userName: string; duration: number}) => void;
'ban': (opts: {userName: string; reason: string}) => void;
'hosting': (opts: {target: string, hostViewers: number}) => void;
'hosted': (opts: {userName: string, hostViewers: number, event: string, timestamp: number}) => void;
'raid': (opts: {userName: string, hostViewers: number, event: string, timestamp: number}) => void;
'stream-started': () => void;
'stream-stopped': () => void;
Expand Down
5 changes: 0 additions & 5 deletions src/helpers/log.ts
Expand Up @@ -62,7 +62,6 @@ enum Levels {
chatOut,
whisperIn,
whisperOut,
host,
raid,
follow,
cheer,
Expand Down Expand Up @@ -95,7 +94,6 @@ const levelFormat = {
ban: '+ban',
unban: '-ban',
follow: '+follow',
host: '+host',
raid: '+raid',
redeem: '+++ redeem:',
cheer: '+cheer',
Expand Down Expand Up @@ -206,9 +204,6 @@ export function unban(message: any) {
export function follow(message: any) {
log(message);
}
export function host(message: any) {
log(message);
}
export function raid(message: any) {
log(message);
}
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/overlaysDefaultValues.ts
Expand Up @@ -129,7 +129,6 @@ const values = {
lastSubMessage: '~ see you on the next stream ~',
streamBy: 'Stream by',
follow: 'Followed by',
host: 'Hosted by',
raid: 'Raided by',
cheer: 'Cheered by',
sub: 'Subscribed by',
Expand All @@ -141,7 +140,6 @@ const values = {
show: {
gameThumbnail: true,
follow: true,
host: true,
raid: true,
sub: true,
subgift: true,
Expand Down
10 changes: 0 additions & 10 deletions src/plugins.ts
Expand Up @@ -67,8 +67,6 @@ const listeners = {
botStarted: generateListener({}, false),
twitchStreamStopped: generateListener({}, false),
twitchRaid: generateListener({ hostViewers: 'number' }, true),
twitchHosted: generateListener({ hostViewers: 'number' }, true),
twitchHosting: generateListener({ hostViewers: 'number' }, true),
twitchChatMessage: generateListener({ message: 'string' }),
twitchCommand: generateListener({ message: 'string' }),
twitchFollow: generateListener(),
Expand Down Expand Up @@ -170,14 +168,6 @@ class Plugins extends Core {
eventEmitter.on('raid', async (data) => {
commonHandler('twitchRaid', data);
});

eventEmitter.on('hosted', async (data) => {
commonHandler('twitchHosted', data);
});

eventEmitter.on('hosting', async (data) => {
this.process('twitchHosting', '', null, data);
});
}

async updateCache () {
Expand Down
3 changes: 1 addition & 2 deletions src/registries/alerts.ts
@@ -1,5 +1,5 @@
import {
Alert, AlertCheer, AlertCommandRedeem, AlertFollow, AlertHost, AlertInterface, AlertRaid, AlertResub, AlertSub, AlertSubcommunitygift, AlertSubgift, AlertTip, EmitData,
Alert, AlertCheer, AlertCommandRedeem, AlertFollow, AlertInterface, AlertRaid, AlertResub, AlertSub, AlertSubcommunitygift, AlertSubgift, AlertTip, EmitData,
} from '@entity/alert';
import { MINUTE } from '@sogebot/ui-helpers/constants';
import { getLocalizedName } from '@sogebot/ui-helpers/getLocalized';
Expand Down Expand Up @@ -163,7 +163,6 @@ class Alerts extends Registry {
await getRepository(AlertSub).delete({ alertId: IsNull() });
await getRepository(AlertSubgift).delete({ alertId: IsNull() });
await getRepository(AlertSubcommunitygift).delete({ alertId: IsNull() });
await getRepository(AlertHost).delete({ alertId: IsNull() });
await getRepository(AlertRaid).delete({ alertId: IsNull() });
await getRepository(AlertTip).delete({ alertId: IsNull() });
await getRepository(AlertCheer).delete({ alertId: IsNull() });
Expand Down

0 comments on commit 19b66ca

Please sign in to comment.