Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cede56e
Added Pizzly
Dec 5, 2022
a45890e
Added frontend
Dec 5, 2022
337c429
Pizzly not yet working
Dec 5, 2022
387edcb
Added flow
Dec 5, 2022
743492b
NA
Dec 5, 2022
57052fd
Getting reddit posts with Pizzly
Dec 8, 2022
c53f06f
Setting up reddit on sign-up
Dec 9, 2022
c6bd348
Started recursive function for comments
Dec 9, 2022
c4094a6
Getting a big set of comments
Dec 12, 2022
22faf71
Working
Dec 12, 2022
4fb41bc
Added Pizzly
Dec 5, 2022
a01a251
Added frontend
Dec 5, 2022
6f614cf
Pizzly not yet working
Dec 5, 2022
47059da
Added flow
Dec 5, 2022
610dc5c
NA
Dec 5, 2022
5097622
Getting reddit posts with Pizzly
Dec 8, 2022
9f27118
Setting up reddit on sign-up
Dec 9, 2022
3dfca0a
Started recursive function for comments
Dec 9, 2022
2dec380
Getting a big set of comments
Dec 12, 2022
9879a55
First commit of reddit connect flow
mariobalca Dec 13, 2022
b18639a
Fix reddit/activity-type-message and translations
mariobalca Dec 13, 2022
7d270c9
Better cli, comments, and securing Pizzly
Dec 13, 2022
dfe58ec
Added vars to docker entrypoint
Dec 14, 2022
1ae0296
Merge branch 'feature/reddit-integration-frontend' into feature/reddi…
Dec 14, 2022
91a47b0
Fix connect
Dec 14, 2022
8a1aa9b
Fix activities HTML
Dec 14, 2022
012e4fd
Added subreddit validation
Dec 14, 2022
b8c01a2
Format
Dec 14, 2022
6d948dd
Track events
Dec 14, 2022
a421c92
Moved to Pizzly 0.4.0
Dec 15, 2022
1fd7300
Address QA items related to frontend
mariobalca Dec 15, 2022
a375cf6
Fix member-channels.vue
mariobalca Dec 16, 2022
d66526b
Add replace for r/
mariobalca Dec 16, 2022
f45d917
Copy tweaks
mariobalca Dec 16, 2022
f39dc09
Merge branch 'main' into feature/reddit-integration
Dec 16, 2022
f536d06
Format
Dec 16, 2022
79e6418
Merge branch 'feature/reddit-integration' of github.com:CrowdDotDev/c…
Dec 16, 2022
aaaa294
Fix reddit-activity-message.vue missing short prop
mariobalca Dec 16, 2022
683c98f
Format
Dec 16, 2022
eb6ec7a
Merge branch 'feature/reddit-integration' of github.com:CrowdDotDev/c…
Dec 16, 2022
79ef41e
Format
Dec 16, 2022
d1c542b
Fixed merge error with PostHog
Dec 16, 2022
84069a0
Changed order of integrations and added copy for the drawer
Dec 16, 2022
177316e
Copy tweak
Dec 16, 2022
a8b73c6
Event tracking
Dec 16, 2022
1570259
Fix track
Dec 16, 2022
cd3ace7
Format
Dec 16, 2022
d90f3ab
Removed isStreamFinished
Dec 17, 2022
777ef3b
Log
Dec 17, 2022
4e60891
Format
Dec 17, 2022
da6b44e
Lint
Dec 17, 2022
62b2191
Removed ability to add more subreddits
Dec 18, 2022
4c0e891
Added Throttling
Dec 18, 2022
ee68574
Merge branch 'main' into feature/reddit-integration
Dec 19, 2022
2bd5230
Merge branch 'main' into feature/reddit-integration
Dec 19, 2022
995c136
Update colors of reddit and hackernews integrations
mariobalca Dec 19, 2022
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
9 changes: 7 additions & 2 deletions backend/.env.dist.local
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ CROWD_GITHUB_CLIENT_SECRET=
CROWD_GITHUB_PRIVATE_KEY=
CROWD_GITHUB_WEBHOOK_SECRET=

# Pizzly settings
CROWD_PIZZLY_URL=http://pizzly:3003
CROWD_PIZZLY_SECRET_KEY=424242
CROWD_PIZZLY_INTEGRATIONS=reddit

# Cohere settings
CROWD_COHERE_API_KEY=

# Vector settings
CROWD_VECTOR_API_KEY=
CROWD_VECTOR_INDEX=
CROWD_QDRANT_HOST=qdrant
CROWD_QDRANT_PORT=6333
4 changes: 4 additions & 0 deletions backend/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,9 @@
"clientSecret": "CROWD_GITHUB_CLIENT_SECRET",
"privateKey": "CROWD_GITHUB_PRIVATE_KEY",
"webhookSecret": "CROWD_GITHUB_WEBHOOK_SECRET"
},
"pizzly": {
"url": "CROWD_PIZZLY_URL",
"secretKey": "CROWD_PIZZLY_SECRET_KEY"
}
}
66 changes: 66 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@aws-sdk/client-comprehend": "^3.159.0",
"@cubejs-client/core": "^0.30.4",
"@google-cloud/storage": "5.3.0",
"@nangohq/pizzly-node": "^0.3.6",
"@octokit/auth-app": "^3.6.1",
"@octokit/graphql": "^4.8.0",
"@octokit/request": "^5.6.3",
Expand Down Expand Up @@ -63,6 +64,7 @@
"express": "4.17.1",
"express-rate-limit": "6.5.1",
"formidable-serverless": "1.1.1",
"he": "^1.2.0",
"helmet": "4.1.1",
"html-to-text": "^8.2.1",
"jsonwebtoken": "8.5.1",
Expand Down
9 changes: 9 additions & 0 deletions backend/src/api/integration/helpers/redditOnboard.ts
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be validating the Permissions.values.integrationCreate instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually. All integrations are like this, though. I will create an issue to move all.

const payload = await new IntegrationService(req).redditOnboard(req.body.subreddits)
await req.responseHandler.success(req, res, payload)
}
55 changes: 55 additions & 0 deletions backend/src/api/integration/helpers/redditValidator.ts
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))
}
5 changes: 5 additions & 0 deletions backend/src/api/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ export default (app) => {
`/discord-authenticate/:tenantId/:guild_id`,
safeWrap(require('./helpers/discordAuthenticate').default),
)
app.put(`/reddit-onboard/:tenantId`, safeWrap(require('./helpers/redditOnboard').default))
app.get(
'/tenant/:tenantId/devto-validate',
safeWrap(require('./helpers/devtoValidators').default),
)
app.get(
'/tenant/:tenantId/reddit-validate',
safeWrap(require('./helpers/redditValidator').default),
)
app.post(
'/tenant/:tenantId/devto-connect',
safeWrap(require('./helpers/devtoCreateOrUpdate').default),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/member/memberQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async (req, res) => {

const payload = await new MemberService(req).query(req.body)

if (req.query.filter && Object.keys(req.query.filter).length > 0) {
if (req.body.filter && Object.keys(req.body.filter).length > 0) {
track('Member Advanced Fitler', { ...payload }, { ...req })
}

Expand Down
5 changes: 5 additions & 0 deletions backend/src/config/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,8 @@ export interface CubeJSConfiguration {
jwtSecret: string
jwtExpiry: string
}

export interface PizzlyConfiguration {
url: string
secretKey: string
}
8 changes: 8 additions & 0 deletions backend/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DevtoConfiguration,
RedisConfiguration,
PosthogConfiguration,
PizzlyConfiguration,
} from './configTypes'

// TODO-kube
Expand Down Expand Up @@ -216,3 +217,10 @@ export const CUBEJS_CONFIG: CubeJSConfiguration = KUBE_MODE
jwtSecret: process.env.CUBE_JS_JWT_SECRET,
jwtExpiry: process.env.CUBE_JS_JWT_EXPIRY,
}

export const PIZZLY_CONFIG: PizzlyConfiguration = KUBE_MODE
? config.get<PizzlyConfiguration>('pizzly')
: {
url: process.env.PIZZLY_URL,
secretKey: process.env.PIZZLY_SECRET_KEY,
}
20 changes: 20 additions & 0 deletions backend/src/database/attributes/member/reddit.ts
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,
},
]
13 changes: 13 additions & 0 deletions backend/src/serverless/integrations/grid/redditGrid.ts
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,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { DiscordIntegrationService } from './integrations/discordIntegrationServ
import { IIntegrationStream, IStepContext } from '../../../types/integration/stepResult'
import { TwitterIntegrationService } from './integrations/twitterIntegrationService'
import { HackerNewsIntegrationService } from './integrations/hackerNewsIntegrationService'
import { RedditIntegrationService } from './integrations/redditIntegrationService'
import { TwitterReachIntegrationService } from './integrations/twitterReachIntegrationService'
import { SlackIntegrationService } from './integrations/slackIntegrationService'
import { GithubIntegrationService } from './integrations/githubIntegrationService'
Expand All @@ -45,6 +46,7 @@ export class IntegrationProcessor extends LoggingBase {
new DevtoIntegrationService(),
new DiscordIntegrationService(),
new HackerNewsIntegrationService(),
new RedditIntegrationService(),
new TwitterIntegrationService(),
new TwitterReachIntegrationService(),
new SlackIntegrationService(),
Expand Down
Loading