Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions packages/apollos-church-api/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ROCK:
API_TOKEN: ${ROCK_TOKEN}
IMAGE_URL: https://s3.amazonaws.com
SHARE_URL: https://newspring.cc
SHORTLINK_SHARE_URL: ns.link/s
# This should match the timezone of the Rock server
TIMEZONE: 'America/New_York'
USE_PLUGIN: true
Expand Down Expand Up @@ -143,6 +144,8 @@ ROCK_MAPPINGS:

WEB_CAMPUS_ID: 20

SHORTLINK_SHARING_SITE_ID: 18

SERVING_GROUP_TYPE_ID: 23
COMMUNITY_GROUP_TYPE_ID: 25
FAMILY_GROUP_TYPE_ID: 10
Expand Down
21 changes: 11 additions & 10 deletions packages/apollos-church-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
},
"dependencies": {
"@apollosproject/config": "^1.2.2",
"@apollosproject/data-connector-algolia-search": "^1.2.2",
"@apollosproject/data-connector-analytics": "^1.2.2",
"@apollosproject/data-connector-bible": "^1.2.2",
"@apollosproject/data-connector-church-online": "^1.2.2",
"@apollosproject/data-connector-cloudinary": "^1.2.2",
"@apollosproject/data-connector-onesignal": "^1.2.2",
"@apollosproject/data-connector-passes": "^1.2.2",
"@apollosproject/data-connector-redis-cache": "^1.2.2",
"@apollosproject/data-connector-rock": "^1.2.2",
"@apollosproject/data-connector-twilio": "^1.2.2",
"@apollosproject/data-schema": "^1.2.2",
Expand All @@ -44,26 +47,24 @@
"@bugsnag/js": "^6.2.0",
"@bugsnag/plugin-express": "^6.2.0",
"apollo-server": "^2.0.5",
"apollo-server-express": "2.4.8",
"btoa": "^1.2.1",
"color": "3.0.0",
"dotenv": "6.0.0",
"express": "^4.17.0",
"graphql": "0.13.2",
"prettier": "1.12.1",
"randomcolor": "0.5.3",
"apollo-server-express": "2.4.8",
"express": "^4.17.0",
"@apollosproject/data-connector-algolia-search": "^1.2.2",
"@apollosproject/data-connector-cloudinary": "^1.2.2",
"@apollosproject/data-connector-redis-cache": "^1.2.2"
"randomcolor": "0.5.3"
},
"devDependencies": {
"@apollosproject/apollo-server-env-mock": "^1.2.2",
"@apollosproject/babel-preset-apollos": "^1.2.2",
"@babel/cli": "^7.4.5",
"@babel/core": "^7.4.5",
"codecov": "3.0.2",
"nodemon": "1.18.7",
"@entria/graphql-findbreakingchanges": "^1.0.1",
"codecov": "3.0.2",
"get-graphql-schema": "^2.1.2",
"graphql-schema-linter": "^0.2.0"
"graphql-schema-linter": "^0.2.0",
"nodemon": "1.18.7"
}
}
}
25 changes: 23 additions & 2 deletions packages/apollos-church-api/src/data/content-items/data-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { get } from 'lodash';
import ApollosConfig from '@apollosproject/config';
import { parseKeyValueAttribute } from '@apollosproject/rock-apollo-data-source';
import sanitizeHtmlNode from 'sanitize-html';
import btoa from 'btoa';
import { createAssetUrl } from '../utils';

const { ROCK, ROCK_CONSTANTS } = ApollosConfig;
const { ROCK, ROCK_CONSTANTS, ROCK_MAPPINGS } = ApollosConfig;

export default class ContentItem extends oldContentItem.dataSource {
getContentItemScriptures = async ({ value: matrixItemGuid }) => {
Expand Down Expand Up @@ -171,9 +172,29 @@ export default class ContentItem extends oldContentItem.dataSource {
.filter(`ContentChannelItemId eq ${parent.id}`)
.first();
}
return `${ROCK.SHARE_URL + contentChannel.channelUrl}/${
const path = `${ROCK.SHARE_URL + contentChannel.channelUrl}/${
parent ? `${parentSlug.slug}/` : ''
}${slug.slug}`;

// check that token has already been made
const link = await this.request('PageShortLinks')
.filter(`Url eq '${path}'`)
.first();
if (link) return `${ROCK.SHORTLINK_SHARE_URL}/${link.token}`;

// generate token
const token = btoa(path)
.replace(/[0-9A-Z+=/]*/g, '')
.slice(-7, -1);
const linkID = await this.post('PageShortLinks', {
Url: path,
SiteId: ROCK_MAPPINGS.SHORTLINK_SHARING_SITE_ID,
Token: token,
});
const newLink = await this.request('PageShortLinks')
.filter(`Id eq ${linkID}`)
.first();
return newLink ? `${ROCK.SHORTLINK_SHARE_URL}/${newLink.token}` : path;
};

getParent = async (childId, channelId) => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6317,6 +6317,11 @@ btoa-lite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"

btoa@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.2.1.tgz#01a9909f8b2c93f6bf680ba26131eb30f7fa3d73"
integrity sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==

buffer-alloc-unsafe@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0"
Expand Down