Skip to content

Commit

Permalink
Merge pull request #219 from ThatConference/feat/discord-info
Browse files Browse the repository at this point in the history
feat: add DiscordInfo type to session base interface
  • Loading branch information
brettski authored Oct 27, 2023
2 parents 8e52d1d + 337c541 commit 737e657
Show file tree
Hide file tree
Showing 20 changed files with 3,059 additions and 2,359 deletions.
5,302 changes: 2,962 additions & 2,340 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "that-api-sessions",
"version": "4.2.0",
"version": "4.3.0",
"description": "THAT Conference Sessions Service.",
"main": "index.js",
"engines": {
Expand All @@ -20,14 +20,14 @@
"prepare": "husky install"
},
"dependencies": {
"@apollo/server": "^4.9.3",
"@apollo/subgraph": "^2.5.5",
"@google-cloud/firestore": "^6.7.0",
"@apollo/server": "^4.9.5",
"@apollo/subgraph": "^2.5.6",
"@google-cloud/firestore": "^7.1.0",
"@google-cloud/trace-agent": "^7.1.2",
"@graphql-tools/load-files": "^7.0.0",
"@graphql-tools/merge": "^9.0.0",
"@graphql-tools/utils": "^10.0.6",
"@sentry/node": "^7.70.0",
"@graphql-tools/utils": "^10.0.7",
"@sentry/node": "^7.75.1",
"@thatconference/api": "~4.3.0",
"@thatconference/schema": "^4.0.0",
"base32-encode": "~1.2.0",
Expand All @@ -38,39 +38,39 @@
"debug": "^4.3.4",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"googleapis": "^126.0.1",
"googleapis": "^128.0.0",
"graphql": "^16.8.1",
"graphql-scalars": "^1.22.2",
"graphql-scalars": "^1.22.4",
"graphql-type-json": "^0.3.2",
"ical-generator": "^5.0.1",
"lodash": "^4.17.21",
"node-fetch": "~2.6.13",
"postmark": "^3.0.19",
"postmark": "^3.1.1",
"response-time": "^2.3.2",
"slugify": "^1.6.6",
"uuid": "^9.0.1"
},
"devDependencies": {
"@babel/cli": "^7.22.15",
"@babel/core": "^7.22.20",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/eslint-parser": "^7.22.15",
"@babel/node": "^7.22.19",
"@babel/preset-env": "^7.22.20",
"@babel/preset-env": "^7.23.2",
"babel-jest": "^29.7.0",
"concurrently": "^8.2.1",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint": "^8.50.0",
"eslint": "^8.52.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest-cli": "^29.7.0",
"nodemon": "^3.0.1",
"prettier-eslint": "^15.0.1",
"prettier-eslint-cli": "^7.1.0"
"prettier-eslint": "^16.1.1",
"prettier-eslint-cli": "^8.0.1"
},
"jest": {
"testEnvironment": "node",
Expand Down
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { constants as apiConstants } from '@thatconference/api';

const constants = {
...apiConstants,
discord: {
baseUrl: 'https://discord.com',
},
};

export default constants;
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/acceptedSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:query:AcceptedSession');

Expand Down Expand Up @@ -48,6 +49,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
location: ({ location }) => location || null,
secondaryLocations: ({ secondaryLocations }) => secondaryLocations || [],
},
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/keynote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:keynote');

Expand Down Expand Up @@ -35,6 +36,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
admin: parent => parent,
event: ({ eventId }) => ({ id: eventId }),
location: ({ location }) => location || null,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/mySession.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import debug from 'debug';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:query:MySession');

Expand All @@ -26,5 +27,6 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
},
};
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/openSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:openspace');

Expand Down Expand Up @@ -35,6 +36,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
admin: parent => parent,
event: ({ eventId }) => ({ id: eventId }),
location: ({ location }) => location || null,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:panel');

Expand Down Expand Up @@ -35,6 +36,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
admin: parent => parent,
event: ({ eventId }) => ({ id: eventId }),
location: ({ location }) => location || null,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:regular');

Expand Down Expand Up @@ -35,6 +36,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
admin: parent => parent,
event: ({ eventId }) => ({ id: eventId }),
location: ({ location }) => location || null,
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/resolvers/queries/workshop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug';
import favoriteStore from '../../../dataSources/cloudFirestore/favorite';
import favoritedByFunc from '../shared/favoritedBy';
import { findAssets } from '../shared/resolveSessionAssets';
import { parseDiscordInfo } from '../shared/discordInfo';

const dlog = debug('that:api:sessions:workshop');

Expand Down Expand Up @@ -35,6 +36,7 @@ export const fieldResolvers = {
dlog('session assets requested');
return findAssets({ entityId, firestore });
},
discord: ({ discord }) => parseDiscordInfo(discord),
admin: parent => parent,
event: ({ eventId }) => ({ id: eventId }),
location: ({ location }) => location || null,
Expand Down
29 changes: 29 additions & 0 deletions src/graphql/resolvers/shared/discordInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import constants from '../../../constants';

export function parseDiscordInfo(discordInfo) {
let discordInfoResult = null;
if (discordInfo) {
const { guildId, channelId, guildScheduledEventId, inviteUrl } =
discordInfo;
discordInfoResult = {
guildId: guildId ?? '',
channelId: channelId ?? '',
guildScheduledEventId: guildScheduledEventId ?? null,
inviteUrl: inviteUrl ?? '',
channelUrl: null,
guildScheduledEventUrl: null,
guildScheduledEventInviteUrl: null,
};
if (guildId && channelId) {
discordInfoResult.channelUrl = `${constants.discord.baseUrl}/channels/${guildId}/${channelId}`;
}
if (guildId && guildScheduledEventId) {
discordInfoResult.guildScheduledEventUrl = `${constants.discord.baseUrl}/events/${guildId}/${guildScheduledEventId}`;
}
if (inviteUrl && guildScheduledEventId) {
discordInfoResult.guildScheduledEventInviteUrl = `${inviteUrl}?event=${guildScheduledEventId}`;
}
}

return discordInfoResult;
}
16 changes: 16 additions & 0 deletions src/graphql/typeDefs/dataTypes/discordInfo.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type DiscordInfo {
"Guild/server this information relates to"
guildId: String
"The voice channel setup for this session"
channelId: String
"The url pointing directly to the channel"
channelUrl: URL
"A discord channel invite for the referenced channel"
inviteUrl: URL
"The event setup for this session which references the channel"
guildScheduledEventId: String
"The url pointing directly to the guild scheduled event"
guildScheduledEventUrl: URL
"Event invite (same as channel with event id parameter)"
guildScheduledEventInviteUrl: URL
}
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/interfaces/base.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ interface Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type AcceptedSession @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"FUTURE: possible rating holder"
rating: [Rating]
"Date time session last updated"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/keynote.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Keynote implements EyesFront & Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/mySession.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type MySession @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo

rating: [Rating]
createdAt: Date!
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/openSpace.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type OpenSpace implements Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/panel.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Panel implements EyesFront & Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/regular.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Regular implements EyesFront & Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/typeDefs/dataTypes/session/workshop.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Workshop implements EyesFront & Base @key(fields: "id") {
communities: [Slug]
"Assets assigned to this session"
assets: [Asset]
"Discord channel information for hosting online session"
discord: DiscordInfo
"Date time session created"
createdAt: Date!
"Date time session last updated"
Expand Down

0 comments on commit 737e657

Please sign in to comment.