Skip to content

Commit

Permalink
added more social kyc steps
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-ares committed Jan 16, 2024
1 parent 159b9b3 commit 10afbee
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 21 deletions.
12 changes: 10 additions & 2 deletions cmd/eskimo-hut/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,11 @@ const docTemplate = `{
3,
4,
5,
6
6,
7,
8,
9,
10
],
"x-enum-varnames": [
"NoneKYCStep",
Expand All @@ -2184,7 +2188,11 @@ const docTemplate = `{
"Social1KYCStep",
"QuizKYCStep",
"Social2KYCStep",
"Social3KYCStep"
"Social3KYCStep",
"Social4KYCStep",
"Social5KYCStep",
"Social6KYCStep",
"Social7KYCStep"
]
}
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/eskimo-hut/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,11 @@
3,
4,
5,
6
6,
7,
8,
9,
10
],
"x-enum-varnames": [
"NoneKYCStep",
Expand All @@ -2178,7 +2182,11 @@
"Social1KYCStep",
"QuizKYCStep",
"Social2KYCStep",
"Social3KYCStep"
"Social3KYCStep",
"Social4KYCStep",
"Social5KYCStep",
"Social6KYCStep",
"Social7KYCStep"
]
}
}
Expand Down
8 changes: 8 additions & 0 deletions cmd/eskimo-hut/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ definitions:
- 4
- 5
- 6
- 7
- 8
- 9
- 10
type: integer
x-enum-varnames:
- NoneKYCStep
Expand All @@ -499,6 +503,10 @@ definitions:
- QuizKYCStep
- Social2KYCStep
- Social3KYCStep
- Social4KYCStep
- Social5KYCStep
- Social6KYCStep
- Social7KYCStep
info:
contact:
name: ice.io
Expand Down
2 changes: 1 addition & 1 deletion cmd/eskimo-hut/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type (
Authorization string `header:"Authorization" swaggerignore:"true" required:"true" example:"some token"`
XAccountMetadata string `header:"X-Account-Metadata" swaggerignore:"true" required:"false" example:"some token"`
UserID string `uri:"userId" required:"true" allowForbiddenWriteOperation:"true" swaggerignore:"true" example:"did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"` //nolint:lll // .
SkipKYCSteps []users.KYCStep `form:"skipKYCSteps" swaggerignore:"true" example:"3,4,5,6"`
SkipKYCSteps []users.KYCStep `form:"skipKYCSteps" swaggerignore:"true" example:"3,4,5,6,7,8,9,10"`
}
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/eskimo-hut/kyc.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (s *service) TryResetKYCSteps( //nolint:gocritic,funlen,gocognit,revive,cyc
ctx = users.ContextWithAuthorization(ctx, req.Data.Authorization) //nolint:revive // .
for _, kycStep := range req.Data.SkipKYCSteps {
switch kycStep { //nolint:exhaustive // .
case users.Social1KYCStep, users.Social2KYCStep, users.Social3KYCStep:
case users.Social1KYCStep, users.Social2KYCStep, users.Social3KYCStep, users.Social4KYCStep, users.Social5KYCStep, users.Social6KYCStep, users.Social7KYCStep:
if err := s.socialRepository.SkipVerification(ctx, kycStep, req.Data.UserID); err != nil {
if errors.Is(err, kycsocial.ErrNotAvailable) || errors.Is(err, kycsocial.ErrDuplicate) {
log.Error(errors.Wrapf(err, "skipVerification failed unexpectedly during tryResetKYCSteps for kycStep:%v,userID:%v",
Expand Down
12 changes: 10 additions & 2 deletions cmd/eskimo/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,11 @@ const docTemplate = `{
3,
4,
5,
6
6,
7,
8,
9,
10
],
"x-enum-varnames": [
"NoneKYCStep",
Expand All @@ -837,7 +841,11 @@ const docTemplate = `{
"Social1KYCStep",
"QuizKYCStep",
"Social2KYCStep",
"Social3KYCStep"
"Social3KYCStep",
"Social4KYCStep",
"Social5KYCStep",
"Social6KYCStep",
"Social7KYCStep"
]
},
"users.MinimalUserProfile": {
Expand Down
12 changes: 10 additions & 2 deletions cmd/eskimo/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,11 @@
3,
4,
5,
6
6,
7,
8,
9,
10
],
"x-enum-varnames": [
"NoneKYCStep",
Expand All @@ -831,7 +835,11 @@
"Social1KYCStep",
"QuizKYCStep",
"Social2KYCStep",
"Social3KYCStep"
"Social3KYCStep",
"Social4KYCStep",
"Social5KYCStep",
"Social6KYCStep",
"Social7KYCStep"
]
},
"users.MinimalUserProfile": {
Expand Down
8 changes: 8 additions & 0 deletions cmd/eskimo/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ definitions:
- 4
- 5
- 6
- 7
- 8
- 9
- 10
type: integer
x-enum-varnames:
- NoneKYCStep
Expand All @@ -146,6 +150,10 @@ definitions:
- QuizKYCStep
- Social2KYCStep
- Social3KYCStep
- Social4KYCStep
- Social5KYCStep
- Social6KYCStep
- Social7KYCStep
users.MinimalUserProfile:
properties:
active:
Expand Down
18 changes: 11 additions & 7 deletions kyc/social/DDL.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- SPDX-License-Identifier: ice License 1.0
CREATE TABLE IF NOT EXISTS social_kyc_unsuccessful_attempts (
created_at timestamp NOT NULL,
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6),
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10),
reason text NOT NULL,
user_id text NOT NULL REFERENCES users(id) ON DELETE CASCADE,
social text NOT NULL CHECK (social = 'twitter' OR social = 'facebook'),
Expand All @@ -11,7 +11,7 @@ ALTER TABLE social_kyc_unsuccessful_attempts
DROP CONSTRAINT social_kyc_unsuccessful_attempts_kyc_step_check;
ALTER TABLE social_kyc_unsuccessful_attempts
ADD CONSTRAINT social_kyc_unsuccessful_attempts_kyc_step_check
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6);
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10);

CREATE INDEX IF NOT EXISTS social_kyc_unsuccessful_attempts_lookup1_ix ON social_kyc_unsuccessful_attempts (kyc_step,social,created_at DESC);
CREATE INDEX IF NOT EXISTS social_kyc_unsuccessful_attempts_lookup2_ix ON social_kyc_unsuccessful_attempts (kyc_step,social,created_at DESC,(CASE
Expand All @@ -23,7 +23,7 @@ CREATE INDEX IF NOT EXISTS social_kyc_unsuccessful_attempts_lookup2_ix ON social

CREATE TABLE IF NOT EXISTS social_kyc_steps (
created_at timestamp NOT NULL,
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6),
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10),
user_id text NOT NULL REFERENCES users(id) ON DELETE CASCADE,
social text NOT NULL CHECK (social = 'twitter' OR social = 'facebook'),
user_handle text NOT NULL,
Expand All @@ -33,7 +33,7 @@ ALTER TABLE social_kyc_steps
DROP CONSTRAINT social_kyc_steps_kyc_step_check;
ALTER TABLE social_kyc_steps
ADD CONSTRAINT social_kyc_steps_kyc_step_check
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6);
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10);

CREATE INDEX IF NOT EXISTS social_kyc_steps_lookup1_ix ON social_kyc_steps (kyc_step,social,created_at DESC);

Expand All @@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS socials (
CREATE TABLE IF NOT EXISTS unsuccessful_social_kyc_alerts (
last_alert_at timestamp NOT NULL,
frequency_in_seconds bigint NOT NULL DEFAULT 300,
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6),
kyc_step smallint NOT NULL CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10),
social text NOT NULL CHECK (social = 'twitter' OR social = 'facebook'),
PRIMARY KEY (kyc_step, social))
WITH (FILLFACTOR = 70);
Expand All @@ -55,11 +55,15 @@ ALTER TABLE unsuccessful_social_kyc_alerts
DROP CONSTRAINT unsuccessful_social_kyc_alerts_kyc_step_check;
ALTER TABLE unsuccessful_social_kyc_alerts
ADD CONSTRAINT unsuccessful_social_kyc_alerts_kyc_step_check
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6);
CHECK (kyc_step = 3 OR kyc_step = 5 OR kyc_step = 6 OR kyc_step = 7 OR kyc_step = 8 OR kyc_step = 9 OR kyc_step = 10);

insert into unsuccessful_social_kyc_alerts (last_alert_at, kyc_step,social)
VALUES (current_timestamp,3, 'twitter'),
(current_timestamp,5, 'twitter'),
(current_timestamp,6, 'twitter')
(current_timestamp,6, 'twitter'),
(current_timestamp,7, 'twitter'),
(current_timestamp,8, 'twitter'),
(current_timestamp,9, 'twitter'),
(current_timestamp,10, 'twitter')
ON CONFLICT (kyc_step, social)
DO NOTHING;
2 changes: 1 addition & 1 deletion kyc/social/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
//nolint:gochecknoglobals // Its loaded once at startup.
AllTypes = []Type{FacebookType, TwitterType}
//nolint:gochecknoglobals // Its loaded once at startup.
AllSupportedKYCSteps = []users.KYCStep{users.Social1KYCStep, users.Social2KYCStep, users.Social3KYCStep}
AllSupportedKYCSteps = []users.KYCStep{users.Social1KYCStep, users.Social2KYCStep, users.Social3KYCStep, users.Social4KYCStep, users.Social5KYCStep, users.Social6KYCStep, users.Social7KYCStep} //nolint:lll // .
)

type (
Expand Down
1 change: 1 addition & 0 deletions kyc/social/translations/10/facebook/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!10 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/10/twitter/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!10 "{{.Username}}"
2 changes: 1 addition & 1 deletion kyc/social/translations/5/facebook/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO configure me! "{{.Username}}"
TODO configure me!5 "{{.Username}}"
2 changes: 1 addition & 1 deletion kyc/social/translations/5/twitter/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO configure me! "{{.Username}}"
TODO configure me!5 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/7/facebook/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!7 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/7/twitter/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!7 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/8/facebook/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!8 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/8/twitter/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!8 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/9/facebook/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!9 "{{.Username}}"
1 change: 1 addition & 0 deletions kyc/social/translations/9/twitter/post_content/en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO configure me!9 "{{.Username}}"
4 changes: 4 additions & 0 deletions users/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const (
QuizKYCStep
Social2KYCStep
Social3KYCStep
Social4KYCStep
Social5KYCStep
Social6KYCStep
Social7KYCStep
)

var (
Expand Down
2 changes: 1 addition & 1 deletion users/users_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (u *User) genSQLUpdate(ctx context.Context, agendaUserIDs []UserID) (sql st
kycStepsLastUpdatedAt = append(kycStepsLastUpdatedAt, *updatedAt.Time)
}
params = append(params, kycStepsLastUpdatedAt)
sql += fmt.Sprintf(", KYC_STEPS_LAST_UPDATED_AT = NULLIF(array_remove(array[coalesce(($%[1]v::timestamp[])[1],(KYC_STEPS_LAST_UPDATED_AT)[1]),coalesce(($%[1]v::timestamp[])[2],(KYC_STEPS_LAST_UPDATED_AT)[2]),coalesce(($%[1]v::timestamp[])[3],(KYC_STEPS_LAST_UPDATED_AT)[3]),coalesce(($%[1]v::timestamp[])[4],(KYC_STEPS_LAST_UPDATED_AT)[4]),coalesce(($%[1]v::timestamp[])[5],(KYC_STEPS_LAST_UPDATED_AT)[5]),coalesce(($%[1]v::timestamp[])[6],(KYC_STEPS_LAST_UPDATED_AT)[6])],null),array[]::timestamp[]), KYC_STEPS_CREATED_AT = NULLIF(array_remove(array[coalesce((KYC_STEPS_CREATED_AT)[1],($%[1]v::timestamp[])[1]),coalesce((KYC_STEPS_CREATED_AT)[2],($%[1]v::timestamp[])[2]),coalesce((KYC_STEPS_CREATED_AT)[3],($%[1]v::timestamp[])[3]),coalesce((KYC_STEPS_CREATED_AT)[4],($%[1]v::timestamp[])[4]),coalesce((KYC_STEPS_CREATED_AT)[5],($%[1]v::timestamp[])[5]),coalesce((KYC_STEPS_CREATED_AT)[6],($%[1]v::timestamp[])[6])],null),array[]::timestamp[])", nextIndex) //nolint:lll // .
sql += fmt.Sprintf(", KYC_STEPS_LAST_UPDATED_AT = NULLIF(array_remove(array[coalesce(($%[1]v::timestamp[])[1],(KYC_STEPS_LAST_UPDATED_AT)[1]),coalesce(($%[1]v::timestamp[])[2],(KYC_STEPS_LAST_UPDATED_AT)[2]),coalesce(($%[1]v::timestamp[])[3],(KYC_STEPS_LAST_UPDATED_AT)[3]),coalesce(($%[1]v::timestamp[])[4],(KYC_STEPS_LAST_UPDATED_AT)[4]),coalesce(($%[1]v::timestamp[])[5],(KYC_STEPS_LAST_UPDATED_AT)[5]),coalesce(($%[1]v::timestamp[])[6],(KYC_STEPS_LAST_UPDATED_AT)[6]),coalesce(($%[1]v::timestamp[])[7],(KYC_STEPS_LAST_UPDATED_AT)[7]),coalesce(($%[1]v::timestamp[])[8],(KYC_STEPS_LAST_UPDATED_AT)[8]),coalesce(($%[1]v::timestamp[])[9],(KYC_STEPS_LAST_UPDATED_AT)[9]),coalesce(($%[1]v::timestamp[])[10],(KYC_STEPS_LAST_UPDATED_AT)[10])],null),array[]::timestamp[]), KYC_STEPS_CREATED_AT = NULLIF(array_remove(array[coalesce((KYC_STEPS_CREATED_AT)[1],($%[1]v::timestamp[])[1]),coalesce((KYC_STEPS_CREATED_AT)[2],($%[1]v::timestamp[])[2]),coalesce((KYC_STEPS_CREATED_AT)[3],($%[1]v::timestamp[])[3]),coalesce((KYC_STEPS_CREATED_AT)[4],($%[1]v::timestamp[])[4]),coalesce((KYC_STEPS_CREATED_AT)[5],($%[1]v::timestamp[])[5]),coalesce((KYC_STEPS_CREATED_AT)[6],($%[1]v::timestamp[])[6]),coalesce((KYC_STEPS_CREATED_AT)[7],($%[1]v::timestamp[])[7]),coalesce((KYC_STEPS_CREATED_AT)[8],($%[1]v::timestamp[])[8]),coalesce((KYC_STEPS_CREATED_AT)[9],($%[1]v::timestamp[])[9]),coalesce((KYC_STEPS_CREATED_AT)[10],($%[1]v::timestamp[])[10])],null),array[]::timestamp[])", nextIndex) //nolint:lll // .
nextIndex++
}
}
Expand Down

0 comments on commit 10afbee

Please sign in to comment.