Skip to content

Commit

Permalink
feat: add DiscordInfo type to session base interface
Browse files Browse the repository at this point in the history
  • Loading branch information
brettski committed Oct 26, 2023
1 parent 8e52d1d commit d8043fd
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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 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 d8043fd

Please sign in to comment.