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

Re-enable sign-ups, add preOptOutStatus #346

Merged
merged 2 commits into from
Dec 2, 2024
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
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ aws:
httpApi:
port: 3001
ownerKey: ypp-owner-key
disableNewSignUps: true
disableNewSignUps: false
joystream:
faucet:
endpoint: http://localhost:3002/register
Expand Down
7 changes: 7 additions & 0 deletions src/repository/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ function createChannelModel(tablePrefix: ResourcePrefix) {
enum: channelYppStatus,
},

// Channel's YPP program participation status before the opt-out bug (ref: https://github.com/Joystream/youtube-synch/issues/337)
preOptOutStatus: {
type: String,
enum: channelYppStatus,
},

phantomKey: {
type: String,
index: {
Expand Down Expand Up @@ -287,6 +293,7 @@ export class ChannelsRepository implements IRepository<YtChannel> {
let lastKey = undefined
const results = []
do {
// FIXME: Is this the reason why /channels returns ALL channels?
let queriedBatch: QueryResponse<AnyItem> = await f(this.model.query(init))
.startAt(lastKey as any)
.exec()
Expand Down
13 changes: 11 additions & 2 deletions src/services/httpApi/controllers/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
VerifyChannelDto,
WhitelistChannelDto,
} from '../dtos'
import { Logger } from 'winston'

@Controller('channels')
@ApiTags('channels')
Expand All @@ -51,7 +52,8 @@ export class ChannelsController {
private qnApi: QueryNodeApi,
private dynamodbService: DynamodbService,
private youtubePollingService: YoutubePollingService,
private contentProcessingClient: ContentProcessingClient
private contentProcessingClient: ContentProcessingClient,
private logger: Logger
) {}

@Post()
Expand Down Expand Up @@ -120,7 +122,7 @@ export class ChannelsController {
...(existingChannel
? {
...existingChannel,
yppStatus: 'Unverified',
yppStatus: existingChannel.preOptOutStatus || 'Unverified',
userAccessToken: channel.userAccessToken,
userRefreshToken: channel.userRefreshToken,
}
Expand All @@ -132,6 +134,13 @@ export class ChannelsController {
joystreamChannelLanguageIso,
}

if (existingChannel && existingChannel.preOptOutStatus) {
this.logger.info(
`Automatically assigned previous ${existingChannel.preOptOutStatus} tier ` +
`to channel ${joystreamChannelId} (${existingChannel.id})`
)
}

// save user and channel
await this.saveUserAndChannel(updatedUser, updatedChannel)

Expand Down
2 changes: 2 additions & 0 deletions src/services/httpApi/dtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class ChannelDto {
@ApiProperty() description: string
@ApiProperty() shouldBeIngested: boolean
@ApiProperty({ enum: channelYppStatus }) yppStatus: ChannelYppStatus
@ApiProperty({ enum: channelYppStatus }) preOptOutStatus: ChannelYppStatus
@ApiProperty() joystreamChannelId: number
@ApiProperty() referrerChannelId?: number
@ApiProperty() videoCategoryId: string
Expand All @@ -133,6 +134,7 @@ export class ChannelDto {
this.language = channel.language
this.shouldBeIngested = channel.shouldBeIngested
this.yppStatus = channel.yppStatus
this.preOptOutStatus = channel.preOptOutStatus
this.thumbnails = channel.thumbnails
this.createdAt = new Date(channel.createdAt)
this.syncStatus = new ChannelSyncStatusDto(syncStatus)
Expand Down
7 changes: 6 additions & 1 deletion src/services/httpApi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from './controllers'
import { MembershipController } from './controllers/membership'
import { ReferrersController } from './controllers/referrers'
import { Logger } from 'winston'

class ApiModule {}

Expand Down Expand Up @@ -70,6 +71,7 @@ export async function bootstrapHttpApi(
await cryptoWaitReady()

const dynamodbService = new DynamodbService(config.aws, false)
const logger = logging.createLogger('HttpApi')

const objectAppModule: DynamicModule = {
module: ApiModule,
Expand Down Expand Up @@ -105,6 +107,10 @@ export async function bootstrapHttpApi(
provide: ContentProcessingClient,
useValue: contentProcessingClient,
},
{
provide: Logger,
useValue: logger,
},
{
provide: 'youtube',
useValue: youtubeApi,
Expand Down Expand Up @@ -146,7 +152,6 @@ export async function bootstrapHttpApi(
})

// API request/response logging
const logger = logging.createLogger('HttpApi')
app.use((request: express.Request, response: express.Response, next: express.NextFunction) => {
const { method, originalUrl } = request

Expand Down
3 changes: 3 additions & 0 deletions src/types/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export class YtChannel {
// This field serves the purpose of nonce to avoid playback attacks
lastActedAt: Date

// Channel's status before opt-out issue (ref: https://github.com/Joystream/youtube-synch/issues/337)
preOptOutStatus: ChannelYppStatus

// Timestamp when the channel verification was processed, either to Verified or Suspended
processedAt: Date

Expand Down
15 changes: 15 additions & 0 deletions ypp-operations/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ export type HubspotYPPContact = {
* Synced video category name
*/
synccategoryname: string

/**
* OPT-OUT BUG PROPS
* (ref: https://github.com/Joystream/youtube-synch/issues/337)
*/

/**
* Date and time when the channel was opted-out due to a bug.
*/
opt_out_bug_date: string

/**
* Status that the channel had before being opted-out.
*/
pre_opt_out_status: ChannelYppStatus
}

export const payableContactProps = [
Expand Down