-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from boostcamp-2020/feat/channel-list
Feat/channel api
- Loading branch information
Showing
7 changed files
with
194 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import express from 'express' | ||
import controller from './channel' | ||
|
||
const express = require('express') | ||
const router = express.Router() | ||
const controller = require('./channel') | ||
|
||
/* GET /api/channle get channel list */ | ||
router.get('/', controller.getChannelList) | ||
|
||
|
||
router.post('/', controller.createChannel) | ||
|
||
/* GET /api/channle/{channelId}/info get channel header info */ | ||
router.get('/:channelId/info', controller.getChannelHeaderInfo) | ||
|
||
/* POST /api/channle/invite invite user to channel */ | ||
router.post('/invite', controller.inviteUser) | ||
|
||
/* PATCH /api/channle/mute mute channel */ | ||
router.patch('/mute', controller.muteChannel) | ||
|
||
module.exports = router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import express from 'express' | ||
|
||
import channelCotroller from './channel' | ||
import searchCotroller from './search' | ||
import userController from './user' | ||
import channelController from './channel' | ||
|
||
const router = express.Router() | ||
|
||
router.use('/channel', channelController) | ||
|
||
router.use('/channel', channelCotroller) | ||
router.use('/search', searchCotroller) | ||
router.use('/user', userController) | ||
|
||
module.exports = router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const express = require('express') | ||
const router = express.Router() | ||
const searchController = require('./search') | ||
|
||
/* POST /api/search/uesr search user */ | ||
router.post('/user', searchController.searchUser) | ||
|
||
module.exports = router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { ChannelConfig } = require('../../model/ChannelConfig') | ||
const { WorkspaceUserInfo } = require('../../model/WorkspaceUserInfo') | ||
|
||
const searchUser = async (req, res, next) => { | ||
try { | ||
const keyword = req.body.keyword | ||
const channelId = req.body.channelId | ||
const workspaceId = req.body.workspaceId | ||
|
||
const userInfo = await WorkspaceUserInfo.find( | ||
{ | ||
$or: [ | ||
{ fullName: new RegExp(keyword, 'i') }, | ||
{ displayName: new RegExp(keyword, 'i') }, | ||
], | ||
workspaceId: workspaceId, | ||
}, | ||
{ displayName: 1, profileUrl: 1, isActive: 1 }, | ||
).lean() | ||
const existMember = await ChannelConfig.find( | ||
{ | ||
workspaceUserInfoId: { $in: userInfo.map(el => el._id) }, | ||
channelId: channelId, | ||
}, | ||
{ _id: 0, workspaceUserInfoId: 1 }, | ||
).lean() | ||
|
||
res.status(200).json({ success: true, result: { userInfo, existMember } }) | ||
} catch (err) { | ||
next(err) | ||
} | ||
} | ||
|
||
module.exports = { | ||
searchUser, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters