Skip to content

Commit 37c2f3f

Browse files
committed
Add socialPermission to submission handlers and content tests
1 parent b4fa227 commit 37c2f3f

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

content-testing/schemas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ const baseVideosSchema = strictObject({
124124
name: string().required(),
125125
url: string().url()
126126
}).required()
127-
)
128-
.required()
127+
).required()
129128
});
130129

131130
const videosSchema = baseVideosSchema.concat(
@@ -149,6 +148,7 @@ const showcasesSchema = strictObject({
149148
title: string().required(),
150149
url: string().url().required(),
151150
submittedOn: dateRangeValidator.required(),
151+
socialPermission: boolean().default(true),
152152
author: strictObject({
153153
name: string().required(),
154154
url: string().url(),

netlify/functions/submission-background.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const crypto = require('crypto');
1414
// authorInstagram: "@the.coding.train"
1515
// url: "https://thecodingtrain.com/tracks",
1616
// videoDir: "challenges/01-test",
17-
// imageExtension: "png|jpg"
17+
// imageExtension: "png|jpg",
18+
// socialPermission: true
1819
// }
1920
// X-Signature: sha256=...
2021

@@ -77,6 +78,10 @@ exports.handler = async function (event) {
7778
json.author.instagram = postInfo.authorInstagram;
7879
}
7980

81+
if ('socialPermission' in postInfo) {
82+
json.socialPermission = postInfo.socialPermission;
83+
}
84+
8085
const jsonString = JSON.stringify(json, null, 2) + '\n';
8186
const jsonContent = Buffer.from(jsonString).toString('base64');
8287

netlify/functions/submission-sync.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const crypto = require('crypto');
1414
// url: "https://thecodingtrain.com/tracks",
1515
// track: "challenges",
1616
// video: "01-starfield",
17+
// socialPermission: true
1718
// }
1819

1920
async function validateImage(imageBase64) {
@@ -89,6 +90,7 @@ exports.handler = async function (event, context) {
8990
authorTwitter: postInfo.authorTwitter,
9091
authorInstagram: postInfo.authorInstagram,
9192
url: postInfo.url,
93+
socialPermission: postInfo.socialPermission,
9294
videoDir:
9395
postInfo.track === 'challenges'
9496
? `challenges/${postInfo.video}`

src/components/PassengerShowcaseForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import * as css from './PassengerShowcaseForm.module.css';
1919
// url: "https://thecodingtrain.com/tracks",
2020
// track: "challenges",
2121
// video: "01-starfield",
22+
// socialPermission: true
2223
// }
2324

2425
const defaultState = {
@@ -46,7 +47,7 @@ const schema = object({
4647
authorEmail: string().label('Your email'),
4748
authorTwitter: string().label('Twitter'),
4849
authorInstagram: string().label('Instagram'),
49-
socialPermission: boolean().default(true)
50+
socialPermission: boolean().required()
5051
});
5152

5253
const useVideosWithShowcase = function () {

0 commit comments

Comments
 (0)