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

2.2.7 #2944

Merged
merged 110 commits into from
Apr 23, 2018
Merged

2.2.7 #2944

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4c3377f
Make it possible for admin to import from shared/
mxstbr Mar 6, 2018
b68ae75
Removed svg default avatars from mobile app
ArturKlajnerok Apr 15, 2018
2f96d8c
Splash view content should take full width
ArturKlajnerok Apr 15, 2018
4e93503
CenteredView for loading text on ThreadFeed
ArturKlajnerok Apr 15, 2018
60d0cc3
Simplified Avatar and removed unneded code in native app
ArturKlajnerok Apr 15, 2018
e26d3af
Updated FacepileContainer to use latest Avatar component in native app
ArturKlajnerok Apr 15, 2018
3dd7ec7
Updated ThreadItem to use latest Facepile component and added few lay…
ArturKlajnerok Apr 15, 2018
2f111fe
Styling ThreadItem in native app
ArturKlajnerok Apr 15, 2018
0c2978d
Using shared UserInfoType in mobile thread
ArturKlajnerok Apr 16, 2018
0dea556
Fixed e2e id name in channelList
ArturKlajnerok Apr 16, 2018
f3e5d83
Fix wrong argument for clickShareLink
Ponjimon Apr 16, 2018
fa2288f
Support FORCE_DEV in stripe config
ArturKlajnerok Apr 16, 2018
b9fdc84
Create now-secret.json for CI test build
ArturKlajnerok Apr 17, 2018
ceb1012
Fix packages for deploying workers
brianlovin Apr 17, 2018
f1407ea
Add pluto as deploy option in PR template
brianlovin Apr 17, 2018
2ea306c
Eslint
brianlovin Apr 17, 2018
edb7565
Fix infinite scroll loading behavior on tall screens
brianlovin Apr 17, 2018
c0880e4
returns the gradients to the text bubbles
superbryntendo Apr 17, 2018
851000d
Merge pull request #2891 from withspectrum/bubble-fix
mxstbr Apr 17, 2018
e7d99e4
Merge pull request #2888 from withspectrum/fix-worker-deploys
mxstbr Apr 17, 2018
7dd214b
Merge pull request #2889 from withspectrum/pluto-deploy-option
mxstbr Apr 17, 2018
f2b9201
Merge pull request #2881 from ArturKlajnerok/fixing-test
mxstbr Apr 17, 2018
dc89c63
Merge pull request #2883 from lookapanda/upsell-fix
mxstbr Apr 17, 2018
9078f41
Merge pull request #2869 from ArturKlajnerok/alpha
mxstbr Apr 17, 2018
77447b4
Update mobile dependencies
mxstbr Apr 17, 2018
e7a2da5
Merge pull request #2893 from withspectrum/update-mobile-deps
mxstbr Apr 17, 2018
0f5eeb2
Update banning users docs
brianlovin Apr 17, 2018
0901ad1
Use the users username for the `return to profile` link
mattgaunt Apr 17, 2018
55ffaee
Merge pull request #2902 from mattgaunt/fix-return-link
brianlovin Apr 17, 2018
040bfbd
Add forked infinitescroll component
brianlovin Apr 17, 2018
ca168ec
Add check for tallscreens
brianlovin Apr 17, 2018
cf2730c
Remove unused helper
brianlovin Apr 17, 2018
f7fd65e
Implement new infinitescroller into views
brianlovin Apr 17, 2018
b972001
Remove console
brianlovin Apr 17, 2018
9e07d39
Fix flow
brianlovin Apr 17, 2018
7e70fa3
Fix flow again
brianlovin Apr 17, 2018
9e99ba5
Add configs to cypress and circleci
brianlovin Apr 17, 2018
45cc668
Merge pull request #2899 from withspectrum/update-banning-users-docs
mxstbr Apr 18, 2018
dadc337
Merge pull request #2903 from withspectrum/add-dashboard-to-cypress
brianlovin Apr 18, 2018
24fc6e4
Merge branch 'alpha' of github.com:withspectrum/spectrum into paginat…
brianlovin Apr 18, 2018
bfc9776
Add comments to confusing code
brianlovin Apr 18, 2018
3e2808b
Merge pull request #2481 from withspectrum/fix-admin-shared
brianlovin Apr 18, 2018
2546318
create security middleware
spartDev Apr 18, 2018
da40f7a
apply security middleware to api
spartDev Apr 18, 2018
1034dbe
apply security middleware to hyperion
spartDev Apr 18, 2018
c575646
apply security middleware to plutot
spartDev Apr 18, 2018
de9f192
fix focus of the chatinput after a user composes a new DM
littleStudent Apr 18, 2018
316d796
:bug: Remove invalid block types of draftjs in chat input
dev-drprasad Apr 19, 2018
487ce26
Merge pull request #2912 from dev-drprasad/remove-list-items-markdown…
mxstbr Apr 19, 2018
968c841
Temporarily disable delete user integration test
mxstbr Apr 19, 2018
6138d70
Fix circleci
mxstbr Apr 19, 2018
0bd5bd2
remove middlewar on pluto
spartDev Apr 19, 2018
9133bf3
fix(src/components/loading/style): align indent
ryota-murakami Apr 19, 2018
9269082
Merge pull request #2915 from withspectrum/disable-delete-user-spec
brianlovin Apr 19, 2018
e96bce7
Neater photo size error positioning; Show error on image added event
johnnynotsolucky Apr 19, 2018
d9da2fc
Merge pull request #2911 from littleStudent/focus-chatinput-after-com…
brianlovin Apr 19, 2018
35c7968
Merge pull request #2890 from withspectrum/pagination-on-tall-screens
brianlovin Apr 19, 2018
bfcea61
Merge pull request #2916 from ryota-murakami/fix/remain-css-tab
brianlovin Apr 19, 2018
9dd1286
Keep CSS media queries inside ChatInputWrapper
johnnynotsolucky Apr 19, 2018
d1f1013
Fix infinite loop in rich text editor
mxstbr Apr 20, 2018
a71d8d9
Merge branch 'alpha' into securityMiddleware
mxstbr Apr 20, 2018
3c3beac
Add dependencies to ap
mxstbr Apr 20, 2018
30ed05d
Merge pull request #2909 from spartDev/securityMiddleware
mxstbr Apr 20, 2018
c9b2de1
fix(src/views/login/style.js): css syntax error. add expected colon
ryota-murakami Apr 20, 2018
7448b5a
refactor(src/components/loading/style): remove dead code.
ryota-murakami Apr 20, 2018
ad04a90
Add local file storage for dev environments
johnnynotsolucky Apr 20, 2018
66f86d4
Merge pull request #2926 from ryota-murakami/fix/css-syntax-error
mxstbr Apr 20, 2018
89d9656
Fix Cypress for forks
mxstbr Apr 20, 2018
166e4a9
Maybe fix user thread last seen tracking
mxstbr Apr 20, 2018
ee25c3f
Merge pull request #2930 from withspectrum/cypress-forks
brianlovin Apr 20, 2018
a9cfcee
add comment explaining
mxstbr Apr 20, 2018
4edbad0
Merge pull request #2919 from johnnynotsolucky/photo-error-styling
brianlovin Apr 20, 2018
c36ef34
Merge pull request #2931 from withspectrum/maybe-fix-user-thread-last…
brianlovin Apr 20, 2018
44b0bbe
Merge pull request #2922 from withspectrum/fix-toolbar-infinite-loop
mxstbr Apr 20, 2018
efcf1f6
Fix graphql errors when viewing community settings with no permissions
brianlovin Apr 20, 2018
895b1db
Fix button alignment on branded login settings
brianlovin Apr 20, 2018
63db4db
Fix error toasts when making changes in community settings
brianlovin Apr 20, 2018
18a7c71
One more error handling fix in toasts
brianlovin Apr 20, 2018
62bbf24
Don't show 'graphql error: ' string in error toasts
brianlovin Apr 20, 2018
39e158b
Allow moderators to manage branded login settings
brianlovin Apr 20, 2018
453cb24
Dont redirect when saving community info
brianlovin Apr 20, 2018
1aec7b9
Show button to channel settings to moderators on channel profile
brianlovin Apr 20, 2018
692df2f
Allow mods to create private channels
brianlovin Apr 20, 2018
5d85072
Allow mods to manage private channel memberships
brianlovin Apr 20, 2018
976b8e6
Fix flow types
johnnynotsolucky Apr 20, 2018
d849dc4
Add local storage options to README
johnnynotsolucky Apr 20, 2018
c8d2604
Fix queues for pending user approved in channel
brianlovin Apr 20, 2018
0a7d2e2
Fix notifications logic for pending requests in private channel
brianlovin Apr 20, 2018
e25a57f
One more fix to pending user request
brianlovin Apr 20, 2018
13469c9
Update typings on pending user request approved queue
brianlovin Apr 20, 2018
5a42399
Fix permission checks when managing private channel join link settings
brianlovin Apr 20, 2018
316f992
Fix tests
brianlovin Apr 20, 2018
b5f0f1f
Skip branded login settings
brianlovin Apr 20, 2018
9115337
Merge pull request #2932 from withspectrum/private-channel-mod-fixes
brianlovin Apr 20, 2018
0598ec5
update readme with yarn run db:reset
alejandronanez Apr 20, 2018
b31ec82
Use a .prettierrc to allow editors to pick up Prettier config.
Apr 21, 2018
9c1b2e6
Set FILE_STORAGE in package.json script; Remove file storage details …
johnnynotsolucky Apr 21, 2018
e810d34
Closes #2748 - Write test for sending messages in private channels.
Apr 22, 2018
9793c18
Move cy.auth and cy.visit to beforeEach() hooks.
Apr 23, 2018
734df14
Fix debug labeling when sending community invite emails
lachlanjc Apr 23, 2018
57836d2
Fix debug labeling when sending mention message emails
lachlanjc Apr 23, 2018
0dccffc
Merge pull request #2940 from lachlanjc/patch-1
mxstbr Apr 23, 2018
734ec7c
Merge pull request #2941 from lachlanjc/patch-2
mxstbr Apr 23, 2018
cdce4bb
Merge pull request #2935 from mikenikles/use-prettierrc
mxstbr Apr 23, 2018
484dcec
Merge pull request #2933 from alejandronanez/add-db-reset-to-docs
mxstbr Apr 23, 2018
e220fef
Merge pull request #2928 from johnnynotsolucky/local-image-storage
mxstbr Apr 23, 2018
62cdd66
Merge pull request #2938 from mikenikles/issue-2748-e2e-test-for-send…
brianlovin Apr 23, 2018
42d1a3d
Merge branch 'alpha' of github.com:withspectrum/spectrum into 2.2.7
brianlovin Apr 23, 2018
d6c1bf8
Version
brianlovin Apr 23, 2018
3e75dbc
Fix consoles and flow
brianlovin Apr 23, 2018
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
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ aliases:
name: Setup and build
command:
|
cp now-secrets.example.json now-secrets.json
yarn run build:web
yarn run build:api

Expand Down Expand Up @@ -107,10 +108,10 @@ jobs:
- run:
name: Danger
when: always
command: test -z $DANGER_GITHUB_API_TOKEN && yarn run danger ci || echo "forks are not allowed to run danger"
command: test $DANGER_GITHUB_API_TOKEN && yarn run danger ci || echo "forks are not allowed to run danger"
- run:
name: Run E2E Tests
command: yarn run test:e2e
command: test $CYPRESS_RECORD_KEY && yarn run test:e2e -- --record || yarn run test:e2e

# Run eslint, flow etc.
test_static_js:
Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- mercury
- hermes
- chronos
- pluto
- mobile

**Run database migrations (delete if no migration was added)**
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ api/.env
.expo
mobile/.expo
test-results.json
public/uploads
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flow-typed
package.json
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ yarn run db:seed
# ⚠️ To empty the database (e.g. if there's faulty data) run yarn run db:drop
```

There's a shortcut for dropping, migrating and seeding the database too:
```sh
yarn run db:reset
```

#### Getting the secrets

While the app will run without any secrets set up, you won't be able to sign in locally. To get that set up, copy the provided example secrets file to the real location:
Expand Down
9 changes: 3 additions & 6 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@
"subscriptions-transport-ws": "^0.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "now build"
"start": "NODE_PATH=../ react-scripts start",
"build": "NODE_PATH=../ react-scripts build",
"test": "NODE_PATH=../ react-scripts test --env=jsdom"
}
}
4 changes: 4 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import express from 'express';
import Raven from 'shared/raven';
import { ApolloEngine } from 'apollo-engine';
import toobusy from 'shared/middlewares/toobusy';
import addSecurityMiddleware from 'shared/middlewares/security';
import { init as initPassport } from './authentication.js';
import type { DBUser } from 'shared/types';

Expand All @@ -28,6 +29,9 @@ app.set('trust proxy', true);
// Return the request if the server is too busy
app.use(toobusy);

// Security middleware.
addSecurityMiddleware(app);

// Send all responses as gzip
app.use(compression());

Expand Down
2 changes: 1 addition & 1 deletion api/models/community.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
const { db } = require('./db');
import { parseRange } from './utils';
import { uploadImage } from '../utils/s3';
import { uploadImage } from '../utils/file-storage';
import getRandomDefaultPhoto from '../utils/get-random-default-photo';
import {
sendNewCommunityWelcomeEmailQueue,
Expand Down
2 changes: 1 addition & 1 deletion api/models/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
const { db } = require('./db');
import { uploadImage } from '../utils/s3';
import { uploadImage } from '../utils/file-storage';
import { createNewUsersSettings } from './usersSettings';
import { sendNewUserWelcomeEmailQueue } from 'shared/bull/queues';
import type { PaginationOptions } from '../utils/paginate-arrays';
Expand Down
20 changes: 18 additions & 2 deletions api/mutations/channel/disableChannelTokenJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ export default async (
return new UserError('You must be signed in to manage this channel.');
}

const [permissions, settings] = await Promise.all([
const [channelPermissions, channel, settings] = await Promise.all([
loaders.userPermissionsInChannel.load([currentUser.id, channelId]),
loaders.channel.load(channelId),
loaders.channelSettings.load(channelId),
]);

if (!permissions.isOwner) {
const communityPermissions = await loaders.userPermissionsInCommunity.load([
currentUser.id,
channel.communityId,
]);

if (!channelPermissions || !communityPermissions) {
return new UserError("You don't have permission to do this.");
}

const canEdit =
channelPermissions.isOwner ||
channelPermissions.isModerator ||
communityPermissions.isOwner ||
communityPermissions.isModerator;

if (!canEdit) {
return new UserError("You don't have permission to do this.");
}

Expand Down
20 changes: 18 additions & 2 deletions api/mutations/channel/enableChannelTokenJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ export default async (
return new UserError('You must be signed in to manage this channel.');
}

const [permissions, settings] = await Promise.all([
const [channelPermissions, channel, settings] = await Promise.all([
loaders.userPermissionsInChannel.load([currentUser.id, channelId]),
loaders.channel.load(channelId),
loaders.channelSettings.load(channelId),
]);

if (!permissions.isOwner) {
const communityPermissions = await loaders.userPermissionsInCommunity.load([
currentUser.id,
channel.communityId,
]);

if (!channelPermissions || !communityPermissions) {
return new UserError("You don't have permission to do this.");
}

const canEdit =
channelPermissions.isOwner ||
channelPermissions.isModerator ||
communityPermissions.isOwner ||
communityPermissions.isModerator;

if (!canEdit) {
return new UserError("You don't have permission to do this.");
}

Expand Down
20 changes: 18 additions & 2 deletions api/mutations/channel/resetChannelJoinToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,28 @@ export default async (
return new UserError('You must be signed in to manage this channel.');
}

const [permissions, settings] = await Promise.all([
const [channelPermissions, channel, settings] = await Promise.all([
loaders.userPermissionsInChannel.load([currentUser.id, channelId]),
loaders.channel.load(channelId),
loaders.channelSettings.load(channelId),
]);

if (!permissions.isOwner) {
const communityPermissions = await loaders.userPermissionsInCommunity.load([
currentUser.id,
channel.communityId,
]);

if (!channelPermissions || !communityPermissions) {
return new UserError("You don't have permission to do this.");
}

const canEdit =
channelPermissions.isOwner ||
channelPermissions.isModerator ||
communityPermissions.isOwner ||
communityPermissions.isModerator;

if (!canEdit) {
return new UserError("You don't have permission to do this.");
}

Expand Down
14 changes: 12 additions & 2 deletions api/mutations/channel/togglePendingUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getUserPermissionsInCommunity,
createMemberInCommunity,
} from '../../models/usersCommunities';
import { sendPrivateChannelRequestApprovedQueue } from 'shared/bull/queues';

type TogglePendingUserInput = {
input: {
Expand Down Expand Up @@ -74,7 +75,9 @@ export default async (
// user is neither a community or channel owner, they don't have permission
if (
currentUserChannelPermissions.isOwner ||
currentUserCommunityPermissions.isOwner
currentUserCommunityPermissions.isOwner ||
currentUserChannelPermissions.isModerator ||
currentUserCommunityPermissions.isModerator
) {
// all checks passed
// determine whether to approve or block them
Expand All @@ -91,6 +94,13 @@ export default async (
input.userId
);

sendPrivateChannelRequestApprovedQueue.add({
userId: input.userId,
channelId: input.channelId,
communityId: channelToEvaluate.communityId,
moderatorId: currentUser.id,
});

// if the user is a member of the parent community, we can return
if (evaluatedUserCommunityPermissions.isMember) {
return Promise.all([channelToEvaluate, approveUser]).then(
Expand All @@ -113,6 +123,6 @@ export default async (
}

return new UserError(
"You don't have permission to make changes to this channel."
"You don't have permission to manage users in this channel."
);
};
4 changes: 3 additions & 1 deletion api/mutations/channel/unblockUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export default async (
// if a user owns the community or owns the channel, they can make this change
if (
currentUserChannelPermissions.isOwner ||
currentUserCommunityPermissions.isOwner
currentUserCommunityPermissions.isOwner ||
currentUserChannelPermissions.isModerator ||
currentUserCommunityPermissions.isModerator
) {
return unblockMemberInChannel(input.channelId, input.userId).then(
() => channelToEvaluate
Expand Down
8 changes: 7 additions & 1 deletion api/mutations/community/disableBrandedLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export default async (
loaders.communitySettings.load(communityId),
]);

if (!permissions.isOwner) {
if (!permissions) {
return new UserError("You don't have permission to do this.");
}

const { isOwner, isModerator } = permissions;

if (!isOwner && !isModerator) {
return new UserError("You don't have permission to do this.");
}

Expand Down
8 changes: 7 additions & 1 deletion api/mutations/community/enableBrandedLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export default async (
loaders.communitySettings.load(communityId),
]);

if (!permissions.isOwner) {
if (!permissions) {
return new UserError("You don't have permission to do this.");
}

const { isOwner, isModerator } = permissions;

if (!isOwner && !isModerator) {
return new UserError("You don't have permission to do this.");
}

Expand Down
8 changes: 7 additions & 1 deletion api/mutations/community/saveBrandedLoginSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export default async (
loaders.communitySettings.load(communityId),
]);

if (!permissions.isOwner) {
if (!permissions) {
return new UserError("You don't have permission to do this.");
}

const { isOwner, isModerator } = permissions;

if (!isOwner && !isModerator) {
return new UserError("You don't have permission to do this.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getDirectMessageThread,
createDirectMessageThread,
} from '../../models/directMessageThread';
import { uploadImage } from '../../utils/s3';
import { uploadImage } from '../../utils/file-storage';
import { storeMessage } from '../../models/message';
import {
setUserLastSeenInDirectMessageThread,
Expand Down
2 changes: 1 addition & 1 deletion api/mutations/message/addMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { stateFromMarkdown } from 'draft-js-import-markdown';
import { EditorState } from 'draft-js';
import type { GraphQLContext } from '../../';
import UserError from '../../utils/UserError';
import { uploadImage } from '../../utils/s3';
import { uploadImage } from '../../utils/file-storage';
import { storeMessage } from '../../models/message';
import { setDirectMessageThreadLastActive } from '../../models/directMessageThread';
import { setUserLastSeenInDirectMessageThread } from '../../models/usersDirectMessageThreads';
Expand Down
2 changes: 1 addition & 1 deletion api/mutations/thread/editThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { GraphQLContext } from '../../';
import type { EditThreadInput } from '../../models/thread';
import UserError from '../../utils/UserError';
import { uploadImage } from '../../utils/s3';
import { uploadImage } from '../../utils/file-storage';
import { getThreads, editThread } from '../../models/thread';
import { getUserPermissionsInCommunity } from '../../models/usersCommunities';
import { getUserPermissionsInChannel } from '../../models/usersChannels';
Expand Down
2 changes: 1 addition & 1 deletion api/mutations/thread/publishThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const debug = require('debug')('api:mutations:thread:publish-thread');
import stringSimilarity from 'string-similarity';
import type { GraphQLContext } from '../../';
import UserError from '../../utils/UserError';
import { uploadImage } from '../../utils/s3';
import { uploadImage } from '../../utils/file-storage';
import {
publishThread,
editThread,
Expand Down
2 changes: 2 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
"graphql-server-express": "1.3.0",
"graphql-subscriptions": "0.4.x",
"graphql-tools": "1.2.3",
"helmet": "^3.12.0",
"highlight.js": "^9.10.0",
"history": "^4.6.1",
"hoist-non-react-statics": "^2.3.1",
"hpp": "^0.2.2",
"imgix-core-js": "^1.0.6",
"immutability-helper": "^2.2.0",
"isomorphic-fetch": "^2.2.1",
Expand Down
7 changes: 5 additions & 2 deletions api/queries/community/billingSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default async (
loaders.stripeCustomers.load(stripeCustomerId),
]);

if (!permissions) return defaultResult;

const { isOwner, isModerator } = permissions;
const customer =
stripeCustomer && stripeCustomer.reduction.length > 0
Expand All @@ -49,8 +51,9 @@ export default async (
: subscriptions;

return {
pendingAdministratorEmail: isOwner ? pendingAdministratorEmail : null,
administratorEmail: isOwner ? administratorEmail : null,
pendingAdministratorEmail:
isOwner || isModerator ? pendingAdministratorEmail : null,
administratorEmail: isOwner || isModerator ? administratorEmail : null,
sources: sources,
invoices: cleanInvoices,
subscriptions: subscriptions,
Expand Down
12 changes: 8 additions & 4 deletions api/queries/community/hasChargeableSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export default async (
) => {
if (!stripeCustomerId || !user) return false;

const {
isOwner,
isModerator,
} = await loaders.userPermissionsInCommunity.load([user.id, id]);
const permissions = await loaders.userPermissionsInCommunity.load([
user.id,
id,
]);

if (!permissions) return null;

const { isOwner, isModerator } = permissions;

if (!isOwner && !isModerator) return null;
return loaders.stripeCustomers.load(stripeCustomerId).then(results => {
Expand Down
Loading