-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Mário Balça <[email protected]>
- Loading branch information
1 parent
aa3dffb
commit 969758e
Showing
48 changed files
with
1,676 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Permissions from '../../../security/permissions' | ||
import IntegrationService from '../../../services/integrationService' | ||
import PermissionChecker from '../../../services/user/permissionChecker' | ||
|
||
export default async (req, res) => { | ||
new PermissionChecker(req).validateHas(Permissions.values.tenantEdit) | ||
const payload = await new IntegrationService(req).redditOnboard(req.body.subreddits) | ||
await req.responseHandler.success(req, res, payload) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import axios from 'axios' | ||
import Error400 from '../../../errors/Error400' | ||
import Permissions from '../../../security/permissions' | ||
import PermissionChecker from '../../../services/user/permissionChecker' | ||
import track from '../../../segment/track' | ||
|
||
export default async (req, res) => { | ||
new PermissionChecker(req).validateHasAny([ | ||
Permissions.values.integrationCreate, | ||
Permissions.values.integrationEdit, | ||
]) | ||
|
||
if (req.query.subreddit) { | ||
try { | ||
const result = await axios.get( | ||
`https://www.reddit.com/r/${req.query.subreddit}/new.json?limit=1`, | ||
) | ||
if ( | ||
result.status === 200 && | ||
result.data.data.children && | ||
result.data.data.children.length > 0 | ||
) { | ||
console.log('here') | ||
track( | ||
'Reddit: subreddit input', | ||
{ | ||
subreddit: req.query.subreddit, | ||
valid: true, | ||
}, | ||
{ ...req }, | ||
) | ||
return req.responseHandler.success(req, res, result.data.data.children) | ||
} | ||
} catch (e) { | ||
track( | ||
'Reddit: subreddit input', | ||
{ | ||
subreddit: req.query.subreddit, | ||
valid: false, | ||
}, | ||
{ ...req }, | ||
) | ||
return req.responseHandler.error(req, res, new Error400(req.language)) | ||
} | ||
} | ||
track( | ||
'Reddit: subreddit input', | ||
{ | ||
subreddit: req.query.subreddit, | ||
valid: false, | ||
}, | ||
{ ...req }, | ||
) | ||
return req.responseHandler.error(req, res, new Error400(req.language)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Attribute } from '../attribute' | ||
import { AttributeType } from '../types' | ||
import { MemberAttributes, MemberAttributeName } from './enums' | ||
|
||
export const RedditMemberAttributes: Attribute[] = [ | ||
{ | ||
name: MemberAttributes[MemberAttributeName.SOURCE_ID].name, | ||
label: MemberAttributes[MemberAttributeName.SOURCE_ID].label, | ||
type: AttributeType.STRING, | ||
canDelete: false, | ||
show: false, | ||
}, | ||
{ | ||
name: MemberAttributes[MemberAttributeName.URL].name, | ||
label: MemberAttributes[MemberAttributeName.URL].label, | ||
type: AttributeType.URL, | ||
canDelete: false, | ||
show: true, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { gridEntry } from './grid' | ||
|
||
export class RedditGrid { | ||
static post: gridEntry = { | ||
score: 10, | ||
isKeyAction: true, | ||
} | ||
|
||
static comment: gridEntry = { | ||
score: 6, | ||
isKeyAction: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.