Skip to content

Commit f871a14

Browse files
committed
Revert "feat/real-time-overhaul with screenshare, bugfixes, improvements (#23)"
This reverts commit 68bb787.
1 parent 68bb787 commit f871a14

File tree

417 files changed

+20494
-51341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+20494
-51341
lines changed

README.md

Lines changed: 29 additions & 84 deletions
Large diffs are not rendered by default.

THIRD-PARTY-LICENSES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The Amazon IVS UGC Web Demo includes the following third-party software/licensin
1919
* web-ui/src/assets/icons/expand-screen.svg
2020
* web-ui/src/assets/icons/fact-check.svg
2121
* web-ui/src/assets/icons/favorite.svg
22+
* web-ui/src/assets/icons/feed.svg
2223
* web-ui/src/assets/icons/fullscreen-exit.svg
2324
* web-ui/src/assets/icons/fullscreen.svg
2425
* web-ui/src/assets/icons/home.svg

cdk/Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ RESET := \033[0m
44

55
.PHONY: help app install bootstrap deploy destroy clean
66

7-
AWS_PROFILE_FLAG = --profile $(AWS_PROFILE)
8-
STAGE ?= dev
9-
PUBLISH ?= false
10-
STACK ?= UGC-$(STAGE)
11-
COGNITO_CLEANUP_SCHEDULE ?= rate(48 hours)
12-
STAGE_CLEANUP_SCHEDULE ?= rate(24 hours)
13-
CDK_OPTIONS = $(if $(AWS_PROFILE),$(AWS_PROFILE_FLAG)) -c stage=$(STAGE) -c publish=$(PUBLISH) -c stackName=$(STACK) -c cognitoCleanupScheduleExp="$(strip $(COGNITO_CLEANUP_SCHEDULE))" -c stageCleanupScheduleExp="$(strip $(STAGE_CLEANUP_SCHEDULE))"
14-
FE_DEPLOYMENT_STACK = UGC-Frontend-Deployment-$(STAGE)
15-
SEED_COUNT ?= 50
16-
OFFLINE_SESSION_COUNT ?= 1
7+
AWS_PROFILE_FLAG = --profile $(AWS_PROFILE)
8+
STAGE ?= dev
9+
PUBLISH ?= false
10+
STACK ?= UGC-$(STAGE)
11+
SCHEDULE ?= rate(48 hours)
12+
CDK_OPTIONS = $(if $(AWS_PROFILE),$(AWS_PROFILE_FLAG)) -c stage=$(STAGE) -c publish=$(PUBLISH) -c stackName=$(STACK) -c scheduleExp="$(strip $(SCHEDULE))"
13+
FE_DEPLOYMENT_STACK = UGC-Frontend-Deployment-$(STAGE)
14+
SEED_COUNT ?= 50
15+
OFFLINE_SESSION_COUNT ?= 1
1716

1817
help: ## Shows this help message
1918
@echo "\n$$(tput bold)Available Rules:$$(tput sgr0)\n"

cdk/README.md

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The outcome of the seed command above is 50 new channels and streams, 20 of thes
3434
make seed JSON=./seed.example.json
3535
```
3636

37-
***NOTE:** Please refer to the [seed.example.json file](./seed.example.json) so that you may create data that the DynamoDB client can use. Incorrect JSON data will lead to errors when seeding.*
37+
**\*NOTE:** Please refer to the [seed.example.json file](./seed.example.json) so that you may create data that the DynamoDB client can use. Incorrect JSON data will lead to errors when seeding.\*
3838

3939
All the environment variables can be used together to generate mock data that suites your needs:
4040

@@ -82,49 +82,3 @@ When the postStreamEvents function receives an event with a `session created` ev
8282
When a `session ended` event is received, the corresponding stream record is grabbed and updated by removing the `isOpen` attribute.
8383

8484
You can find the Stream events API code in the `/streamEventsApi` folder.
85-
86-
## Scheduled resource cleanup AWS Lambdas
87-
88-
The scheduled resource cleanup lambdas are created when the stack is deployed. No additional steps are necessary to set up and trigger these functions. The lambda functions exist in the `cdk/lambdas` folder. The schedule can be customized in the `cdk/Makefile`. AWS Lambda supports standard rate and cron expressions for frequencies of up to once per minute. Read more about [schedule expressions using rate or cron](https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html).
89-
90-
### Amazon IVS idle stages cleanup
91-
92-
The cleanup lambda function follows these steps:
93-
1. It retrieves a list of all stages
94-
2. The `getIdleStageArn` helper function is employed to filter out idle stages that have been in existence for at least 1 hour
95-
3. Subsequently, the filtered idle stages are deleted.
96-
97-
### Amazon Cognito unverified users cleanup
98-
99-
The cleanup lambda function follows these steps:
100-
1. It retrieves a list of users with a `UNCONFIRMED` status
101-
2. Within the unconfirmed users, we filter for users that have existed for at least 24 hours
102-
3. Finally, the filtered unverified and expired users are deleted both from the Cognito user pool and AWS DynamoDB channels table.
103-
104-
105-
## Amazon IVS Real-time host disconnect event handler
106-
107-
Amazon IVS host disconnect event cleanup is designed to delete active stages for which hosts have been disconnected from the session for at least 3 minutes. Upon a host's disconnection from a stage, the responsible endpoint follows these steps:
108-
1. Extracts the host's channel ID from the request body, accommodating both object and JSON string formats
109-
2. It retrieves the corresponding host details, including the stage and session, and formats them into a message body
110-
3. This structured data is sent to an Amazon SQS queue for additional processing. It's important to highlight that the message comes with a 3-minute delay, allowing the host sufficient time to rejoin if they choose to
111-
4. After 3-minute wait time, SQS triggers deleteStage lambda function.
112-
113-
### Amazon IVS Real-time host disconnect event cleanup triggers
114-
115-
This flow is triggered by:
116-
1. Beacon API [Beacon API documention](https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API)
117-
2. Stage participantConnectionChangedEvent event [STAGE_CONNECTION_STATE_CHANGED](https://aws.github.io/amazon-ivs-web-broadcast/docs/sdk-reference/enums/StageEvents#stage_connection_state_changed)
118-
3. EventBridge
119-
4. SQS [Amazon FIFO SQS](#amazon-fifo-sqs)
120-
121-
### Amazon IVS real-time host disconnect event lamnda cleanup
122-
123-
The cleanup lambda function follows these steps:
124-
1. Lambda receives a message from the SQS queue
125-
2. Checks if the host is present in the stage for potential reconnection
126-
3. If the host is not detected in the stage, deletes the stage
127-
4. Updates the channel table to reflect changes such as the removal/nullification of the stageId and stageCreationDate fields.
128-
129-
### Amazon FIFO SQS
130-
A FIFO queue using content body for message deduplication and a 3-minute delayed delivery, allowing the host sufficient time to rejoin if they choose to.

cdk/api/__mocks__/userInfo.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

cdk/api/buildServer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import channelRouters from './channel';
55
import channelsRouters from './channels';
66
import metricsRouter from './metrics/';
77
import productsRouters from './product';
8-
import stagesRouter from './stages';
98

109
import configureRoute from './shared/hooks/configureRoute';
1110
import { MAX_SERVER_PARAM_LENGTH } from './shared/constants';
@@ -50,8 +49,6 @@ const buildServer = () => {
5049
// Create /products authenticated resources
5150
server.register(productsRouters, { prefix: 'products' });
5251
}
53-
54-
server.register(stagesRouter, { prefix: 'stages' });
5552
}
5653

5754
if (['all', 'metrics'].includes(serviceName)) {

cdk/api/channel/authRouter/__tests__/banUser.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import {
22
GetItemCommandOutput,
33
UpdateItemCommand
44
} from '@aws-sdk/client-dynamodb';
5+
import {
6+
DisconnectUserCommand,
7+
SendEventCommand
8+
} from '@aws-sdk/client-ivschat';
59
import { mockClient } from 'aws-sdk-client-mock';
610

711
import buildServer from '../../../buildServer';

cdk/api/channel/authRouter/addToFollowingList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getChannelId
1515
} from '../../shared/helpers';
1616
import { getUser, getUserByUsername } from '../helpers';
17-
import { UserContext } from '../../shared/authorizer';
17+
import { UserContext } from '../authorizer';
1818

1919
export const getFollowingChannelArn = async ({
2020
reply,

cdk/api/channel/authRouter/banUser.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
import { FastifyReply, FastifyRequest } from 'fastify';
22
import { convertToAttr, unmarshall } from '@aws-sdk/util-dynamodb';
3+
import {
4+
DisconnectUserCommand,
5+
SendEventCommand
6+
} from '@aws-sdk/client-ivschat';
37
import { UpdateItemCommand } from '@aws-sdk/client-dynamodb';
48

5-
import { dynamoDbClient, getUserByChannelArn } from '../../shared/helpers';
9+
import {
10+
dynamoDbClient,
11+
getUserByChannelArn,
12+
isIvsChatError,
13+
ivsChatClient
14+
} from '../../shared/helpers';
615
import { getUser } from '../helpers';
716
import {
817
UNEXPECTED_EXCEPTION,
918
BAN_USER_EXCEPTION,
1019
USER_NOT_FOUND_EXCEPTION
1120
} from '../../shared/constants';
12-
import { UserContext } from '../../shared/authorizer';
21+
import { UserContext } from '../authorizer';
1322

1423
type BanUserRequestBody = { bannedChannelArn?: string };
1524

@@ -21,7 +30,7 @@ const handler = async (
2130
'user'
2231
) as UserContext;
2332
const { bannedChannelArn } = request.body;
24-
let chatRoomOwnerChannelArn;
33+
let chatRoomArn, chatRoomOwnerChannelArn, bannedUsername;
2534

2635
// Check input
2736
if (!bannedChannelArn) {
@@ -37,7 +46,8 @@ const handler = async (
3746
// Retrieve the chat room data for the requester's channel
3847
try {
3948
const { Item: UserItem = {} } = await getUser(sub);
40-
({ channelArn: chatRoomOwnerChannelArn } = unmarshall(UserItem));
49+
({ chatRoomArn, channelArn: chatRoomOwnerChannelArn } =
50+
unmarshall(UserItem));
4151

4252
// Disallow users from banning themselves from their own channel
4353
if (bannedChannelArn === chatRoomOwnerChannelArn) {
@@ -73,7 +83,8 @@ const handler = async (
7383
}
7484

7585
// Add the bannedUserSub to the bannedUserSubs set in the user table
76-
const { id: bannedUserSub } = unmarshall(BannedUserItems[0]);
86+
const { id: bannedUserSub, username } = unmarshall(BannedUserItems[0]);
87+
bannedUsername = username;
7788

7889
await dynamoDbClient.send(
7990
new UpdateItemCommand({

cdk/api/channel/authRouter/changeUserPreferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FastifyReply, FastifyRequest } from 'fastify';
44
import { CHANGE_USER_PREFERENCES_EXCEPTION } from '../../shared/constants';
55
import { updateDynamoItemAttributes } from '../../shared/helpers';
66
import { processAssetPreference, Preference } from '../helpers';
7-
import { UserContext } from '../../shared/authorizer';
7+
import { UserContext } from '../authorizer';
88

99
interface ChangeUserPreferencesRequestBody {
1010
[key: string]: Preference;

0 commit comments

Comments
 (0)