diff --git a/.eslintignore b/.eslintignore index 9ed3e5361..069144d94 100644 --- a/.eslintignore +++ b/.eslintignore @@ -13,5 +13,5 @@ plugins/* !plugins/coral-plugin-viewing-options !plugins/coral-plugin-comment-content !plugins/talk-plugin-permalink -!plugins/talk-plugin-avatar + node_modules diff --git a/.gitignore b/.gitignore index e94a01a6c..0be1266c6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,5 @@ plugins/* !plugins/coral-plugin-viewing-options !plugins/coral-plugin-comment-content !plugins/talk-plugin-permalink -!plugins/talk-plugin-avatar **/node_modules/* diff --git a/plugins/talk-plugin-avatar/client/.babelrc b/plugins/talk-plugin-avatar/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-avatar/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-avatar/client/.eslintrc.json b/plugins/talk-plugin-avatar/client/.eslintrc.json deleted file mode 100644 index 9fe56bd14..000000000 --- a/plugins/talk-plugin-avatar/client/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es6": true, - "mocha": true - }, - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - } - }, - "parser": "babel-eslint", - "plugins": [ - "react" - ], - "rules": { - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error", - "no-console": ["warn", { "allow": ["warn", "error"] }] - } -} diff --git a/plugins/talk-plugin-avatar/client/assets/avatar-placeholder.png b/plugins/talk-plugin-avatar/client/assets/avatar-placeholder.png deleted file mode 100644 index 2e828f0fb..000000000 Binary files a/plugins/talk-plugin-avatar/client/assets/avatar-placeholder.png and /dev/null differ diff --git a/plugins/talk-plugin-avatar/client/components/UserAvatar.js b/plugins/talk-plugin-avatar/client/components/UserAvatar.js deleted file mode 100644 index a87669540..000000000 --- a/plugins/talk-plugin-avatar/client/components/UserAvatar.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -import styles from './styles.css'; -import avatarPlaceholder from '../assets/avatar-placeholder.png'; - -const UserAvatar = ({comment: {user}}) => - ; - -export default UserAvatar; diff --git a/plugins/talk-plugin-avatar/client/components/styles.css b/plugins/talk-plugin-avatar/client/components/styles.css deleted file mode 100644 index fc6111845..000000000 --- a/plugins/talk-plugin-avatar/client/components/styles.css +++ /dev/null @@ -1,4 +0,0 @@ -.avatarPlaceholder { - height: 50px; - width: 50px; -} \ No newline at end of file diff --git a/plugins/talk-plugin-avatar/client/containers/UserAvatar.js b/plugins/talk-plugin-avatar/client/containers/UserAvatar.js deleted file mode 100644 index 76b558e05..000000000 --- a/plugins/talk-plugin-avatar/client/containers/UserAvatar.js +++ /dev/null @@ -1,12 +0,0 @@ -import {gql} from 'react-apollo'; -import {withFragments} from 'plugin-api/beta/client/hocs'; -import UserAvatar from '../components/UserAvatar'; - -export default withFragments({ - comment: gql` - fragment UserAvatar_comment on Comment { - user { - avatar - } - }` -})(UserAvatar); diff --git a/plugins/talk-plugin-avatar/client/index.js b/plugins/talk-plugin-avatar/client/index.js deleted file mode 100644 index a706a41d0..000000000 --- a/plugins/talk-plugin-avatar/client/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import UserAvatar from './components/UserAvatar'; - -export default { - slots: { - commentAvatar: [UserAvatar] - } -}; diff --git a/plugins/talk-plugin-avatar/index.js b/plugins/talk-plugin-avatar/index.js deleted file mode 100644 index fca0aafee..000000000 --- a/plugins/talk-plugin-avatar/index.js +++ /dev/null @@ -1,74 +0,0 @@ -// We need the UserModel because we need to update the user. -const UserModel = require('models/user'); - -// Get some middleware to use with the webhook. -const auth = require('middleware/authentication'); -const authz = require('middleware/authorization'); - -// Load some config from the environment. This could be changed to a settings -// option later if you want to go that route. -const DEFAULT_AVATAR = process.env.DEFAULT_AVATAR; - -module.exports = { - - // The new type definitions provides the new "avatar" field needed to inject - // into the User type. - typeDefs: ` - type User { - avatar: String - } - `, - - // The User resolver will return the avatar from the embedded user metadata. - resolvers: { - User: { - avatar(user) { - if (user && user.metadata && user.metadata.avatar) { - return user.metadata.avatar; - } - - return DEFAULT_AVATAR; - } - } - }, - - // The custom router routes that we add here will allow an external system to - // update the avatar when it changes on the remote system. Note that we do - // use the auth/authz middleware, checking for the ADMIN role. This can be - // used in conjunction with a personal access token generated from an ADMIN. - router(router) { - router.post('/webhooks/user_update', auth, authz.needed('ADMIN'), async (req, res, next) => { - - // We expect that the payload for the new avatar is in the following form: - // - // { - // "id": "123123-123123-12312313", - // "avatar": "https://great-cdn.cloudfront.net/best-photo.jpg" - // ... - // } - - // Extract the data from the payload. - let { - id, - avatar - } = req.body; - - try { - - // Update the user model. - await UserModel.update({id}, { - $set: { - 'metadata.avatar': avatar - } - }); - - } catch (e) { - return next(e); - } - - // Respond with a `202 Accepted` to indicate that we were able to process - // the update. - res.status(202).end(); - }); - } -}; diff --git a/plugins/talk-plugin-avatar/package.json b/plugins/talk-plugin-avatar/package.json deleted file mode 100644 index c652a86d0..000000000 --- a/plugins/talk-plugin-avatar/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "talk-plugin-avatar", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Belen Curcio ", - "license": "ISC" -} diff --git a/plugins/talk-plugin-avatar/yarn.lock b/plugins/talk-plugin-avatar/yarn.lock deleted file mode 100644 index fb57ccd13..000000000 --- a/plugins/talk-plugin-avatar/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - -