Skip to content

Commit

Permalink
Merge pull request #249 from TogetherCrew/239-new-apis-for-communitie…
Browse files Browse the repository at this point in the history
…s-and-platforms

Community Centric to development
  • Loading branch information
Behzad-rabiei authored Dec 16, 2023
2 parents 5e731ef + 8d214db commit a4f17f0
Show file tree
Hide file tree
Showing 108 changed files with 6,077 additions and 5,410 deletions.
9 changes: 4 additions & 5 deletions .env.example → .envs.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ DB_PORT=
DB_USER=
DB_PASSWORD=
DB_NAME=
DISCORD_TRY_NOW_CALLBACK_URI=
DISCORD_LOGIN_CALLBACK_URI=
DISCORD_CONNECT_GUILD_CALLBACK_URI=
DISCORD_AUTHORIZE_CALLBACK_URI=
DISCORD_CONNECT_CALLBACK_URI=
DISCROD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_BOT_TOKEN=
TWITTER_LOGIN_CALLBACK_URI=
TWITTER_CONNECT_CALLBACK_URI=
TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=
JWT_SECRET=
Expand All @@ -29,7 +28,7 @@ SENTRY_DSN=
SENTRY_ENV=
NEO4J_PROTOCOL=
NEO4J_HOST=
NEO4J_PORT=
NEO4J_PORT=
NEO4J_USER=
NEO4J_PASSWORD=
NEO4J_DB=
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# env vars
src/config/dev.env
src/config/test.env
*.env

# compiled output
/lib
Expand Down
9 changes: 9 additions & 0 deletions .migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"lastRun": "1702287534517-migrate-to-cc.ts",
"migrations": [
{
"title": "1702287534517-migrate-to-cc.ts",
"timestamp": 1702475464508
}
]
}
33 changes: 33 additions & 0 deletions __tests__/fixtures/community.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Types } from 'mongoose';
import { Community } from '@togethercrew.dev/db';

interface CommunityFixture {
_id: Types.ObjectId;
name: string;
avatarURL?: string;
users?: Types.ObjectId[];
platforms?: Types.ObjectId[];
}


export const communityOne: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Alpha",
avatarURL: "path/to/avatar1.png",
};

export const communityTwo: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Beta",
};

export const communityThree: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Teta",
};

export const insertCommunities = async function <Type>(communities: Array<Type>) {
for (const community of communities) {
await Community.create(community);
}
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IChannel } from '@togethercrew.dev/db';
import { Connection } from 'mongoose';

export const channel1: IChannel = {
export const discordChannel1: IChannel = {
channelId: '987654321098765432',
name: 'Channel 1',
parentId: null,
Expand All @@ -17,7 +17,7 @@ export const channel1: IChannel = {
deletedAt: null
};

export const channel2: IChannel = {
export const discordChannel2: IChannel = {
channelId: '234567890123456789',
name: 'Channel 2',
parentId: '987654321098765432',
Expand All @@ -38,7 +38,7 @@ export const channel2: IChannel = {
deletedAt: null
};

export const channel3: IChannel = {
export const discordChannel3: IChannel = {
channelId: '345678901234567890',
name: 'Channel 3',
parentId: '987654321098765432',
Expand All @@ -59,14 +59,14 @@ export const channel3: IChannel = {
deletedAt: null
};

export const channel4: IChannel = {
export const discordChannel4: IChannel = {
channelId: '345678901234567000',
name: 'Channel 4',
parentId: null,
deletedAt: null
};

export const channel5: IChannel = {
export const discordChannel5: IChannel = {
channelId: '345678901234567333',
name: 'Channel 5',
parentId: '987654321098765432',
Expand All @@ -75,5 +75,7 @@ export const channel5: IChannel = {


export const insertChannels = async function <Type>(channels: Array<Type>, connection: Connection) {
await connection.models.Channel.insertMany(channels.map((channel) => (channel)));
for (const channel of channels) {
await connection.models.Channel.create(channel);
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Connection } from 'mongoose';

export const guildMemberOne = {
export const discordGuildMember1 = {
discordId: "123456789",
username: "behzad_rabiei",
avatar: null,
Expand All @@ -12,7 +12,7 @@ export const guildMemberOne = {
globalName: "Behzad"
};

export const guildMemberTwo = {
export const discordGuildMember2 = {
discordId: "987654321",
username: "mrjackalop",
avatar: "AvatarLink",
Expand All @@ -24,7 +24,7 @@ export const guildMemberTwo = {
globalName: "Danielo"
};

export const guildMemberThree = {
export const discordGuildMember3 = {
discordId: "555555555",
username: "amin_torabi",
avatar: "AvatarLink",
Expand All @@ -36,7 +36,7 @@ export const guildMemberThree = {
globalName: null
};

export const guildMemberFour = {
export const discordGuildMember4 = {
discordId: "444444444",
username: "zc_behzad",
avatar: "AvatarLink",
Expand All @@ -48,7 +48,7 @@ export const guildMemberFour = {
globalName: null
};

export const guildMemberFive = {
export const discordGuildMember5 = {
discordId: "444444444",
username: "User4",
avatar: "AvatarLink",
Expand All @@ -60,7 +60,9 @@ export const guildMemberFive = {
globalName: null
};

export const insertGuildMembers = async function <Type>(guildMembers: Array<Type>, connection: Connection) {
await connection.models.GuildMember.insertMany(guildMembers.map((guildMember) => (guildMember)));

export const insertGuildMembers = async function <Type>(guildMembers: Array<Type>, connection: Connection) {
for (const guildMember of guildMembers) {
await connection.models.GuildMember.create(guildMember);
}
};
112 changes: 112 additions & 0 deletions __tests__/fixtures/discord/guilds.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// import { Guild } from "@togethercrew.dev/db";
// import { userOne, userTwo } from "../user.fixture";
// import { Types } from "mongoose"

// export const discordResponseGuildOne = {
// id: "681946187490000901",
// name: "guildOne",
// icon: "947f3e19e6e36a2679c6fe854b79a601",
// owner: false,
// permissions: 2147483647,
// features: [
// "APPLICATION_COMMAND_PREMISSION_V2"
// ],
// Permission_new: "4398046511103"
// };

// export const discordResponseGuildTwo = {
// id: "681946187490000902",
// name: "guildTwo",
// icon: "947f3e19e6e36a2679c6fe854b79a602",
// owner: false,
// permissions: 104189505,
// features: [
// "APPLICATION_COMMAND_PREMISSION_V2"
// ],
// Permission_new: "1071698529857"
// };

// export const discordResponseGuildThree = {
// id: "681946187490000902",
// name: "guildTwo",
// icon: "947f3e19e6e36a2679c6fe854b79a602",
// owner: false,
// permissions: 1342178320,
// features: [
// "APPLICATION_COMMAND_PREMISSION_V2"
// ],
// Permission_new: "1071698529857"
// };

// export const guildOne = {
// _id: new Types.ObjectId(),
// guildId: "681946187490000901",
// user: userOne.discordId,
// name: 'guildOne',
// isDisconnected: false,
// isInProgress: true,
// icon: 'IconOne'
// }

// export const guildTwo = {
// _id: new Types.ObjectId(),
// guildId: "681946187490000803",
// user: userOne.discordId,
// name: 'guildTwo',
// isDisconnected: true,
// isInProgress: false,
// icon: 'IconTwo'

// }

// export const guildThree = {
// _id: new Types.ObjectId(),
// guildId: "681946187490000802",
// user: userTwo.discordId,
// name: 'guildThree',
// isDisconnected: true,
// isInProgress: false,
// icon: 'IconThree'

// }

// export const guildFour = {
// _id: new Types.ObjectId(),
// guildId: "681946187490000801",
// user: userTwo.discordId,
// name: 'guildFour',
// isDisconnected: false,
// isInProgress: true,
// icon: 'IconFour'
// }

// export const guildFive = {
// _id: new Types.ObjectId(),
// guildId: "681946187490000999",
// user: userOne.discordId,
// name: 'guildFive',
// isDisconnected: false,
// isInProgress: true,
// icon: 'IconFive',
// selectedChannels: [
// {
// channelId: '987654321098765432',
// channelName: 'Channel 1'
// },
// {
// channelId: '234567890123456789',
// channelName: 'Channel 2'
// },
// {
// channelId: '345678901234567000',
// channelName: 'Channel 4'
// },
// ]
// }


// export const insertGuilds = async function <Type>(guilds: Array<Type>) {
// await Guild.insertMany(guilds.map((guild) => (guild)));
// };


Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { IRole } from '@togethercrew.dev/db';
import { Connection } from 'mongoose';

export const role1: IRole = {
export const discordRole1: IRole = {
roleId: '652345789987654321',
name: 'Admin',
color: 0xFF0000,
deletedAt: null
};

export const role2: IRole = {
export const discordRole2: IRole = {
roleId: '987654321123456789',
name: 'Moderator',
color: 0x00FF00,
deletedAt: null
};

export const role3: IRole = {
export const discordRole3: IRole = {
roleId: '123456789987654321',
name: 'Member',
color: 0x0000FF,
deletedAt: null
};

export const role4: IRole = {
export const discordRole4: IRole = {
roleId: '123456789987654399',
name: 'Member',
color: 0x0000FF,
deletedAt: new Date()
};

export const insertRoles = async function <Type>(roles: Array<Type>, connection: Connection) {
await connection.models.Role.insertMany(roles.map((role) => (role)));
for (const role of roles) {
await connection.models.Role.create(role);
}
};
Loading

0 comments on commit a4f17f0

Please sign in to comment.