Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2811 from withspectrum/spectrum-api-key-switch
Browse files Browse the repository at this point in the history
Swap spectrum secrets
  • Loading branch information
brianlovin authored Apr 10, 2018
2 parents 79e093a + 7170895 commit 17b294f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions athena/queues/moderationEvents/message.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @flow
const debug = require('debug')('athena:queue:channel-notification');
const debug = require('debug')('athena:queue:moderation-events:message');
import { getUserById } from '../../models/user';
import { getThreadById } from '../../models/thread';
import { getCommunityById } from '../../models/community';
import { getChannelById } from '../../models/channel';
import type { DBMessage } from 'shared/types';
import { toState, toPlainText } from 'shared/draft-utils';
import getSpectrumScore from './spectrum';
import getPerspectiveScore from './perspective';
Expand Down
5 changes: 2 additions & 3 deletions athena/queues/moderationEvents/perspective.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// @flow
const debug = require('debug')('athena:queue:moderation-events:perspective');
require('now-env');
import axios from 'axios';
const PERSPECTIVE_API_KEY = process.env.PERSPECTIVE_API_KEY;

if (!PERSPECTIVE_API_KEY) {
console.log(
'No API key for Perspective provided, not sending moderation events.'
);
debug('No API key for Perspective provided, not sending moderation events.');
}

export default async (text: string) => {
Expand Down
11 changes: 10 additions & 1 deletion athena/queues/moderationEvents/spectrum.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
// @flow
const debug = require('debug')('athena:queue:moderation-events:spectrum');
require('now-env');
import axios from 'axios';
const SPECTRUM_MODERATION_API_KEY = process.env.SPECTRUM_MODERATION_API_KEY;

if (!SPECTRUM_MODERATION_API_KEY) {
debug('No API key for Spectrum provided, not sending moderation events.');
}

export default async (text: string, contextId: string, userId: string) => {
if (!SPECTRUM_MODERATION_API_KEY) return;

const request = await axios({
method: 'post',
url: 'https://api.prod.getspectrum.io/api/v1/classification',
headers: {
Authorization: 'Apikey 205276812f89fcec2856d48c9192b2588',
Authorization: `Apikey ${SPECTRUM_MODERATION_API_KEY}`,
'Content-Type': 'application/json',
},
data: {
Expand Down
3 changes: 1 addition & 2 deletions athena/queues/moderationEvents/thread.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @flow
const debug = require('debug')('athena:queue:channel-notification');
const debug = require('debug')('athena:queue:moderation-events:thread');
import { getUserById } from '../../models/user';
import { getCommunityById } from '../../models/community';
import { getChannelById } from '../../models/channel';
import type { DBThread } from 'shared/types';
import { toState, toPlainText } from 'shared/draft-utils';
import getSpectrumScore from './spectrum';
import getPerspectiveScore from './perspective';
Expand Down
3 changes: 2 additions & 1 deletion now.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ALGOLIA_APP_ID": "@algolia-app-id",
"ALGOLIA_API_SECRET": "@algolia-api-secret",
"APOLLO_ENGINE_API_KEY": "@apollo-engine-api-key",
"API_TOKEN_SECRET": "@api-token-secret"
"API_TOKEN_SECRET": "@api-token-secret",
"SPECTRUM_MODERATION_API_KEY": "@spectrum-moderation-api-key"
}
}

0 comments on commit 17b294f

Please sign in to comment.