mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-01-25 02:08:24 +00:00
add inbound and outbound messaging support
This commit is contained in:
@@ -5,6 +5,7 @@ const Account = require('../../models/account');
|
||||
const Webhook = require('../../models/webhook');
|
||||
const ApiKey = require('../../models/api-key');
|
||||
const ServiceProvider = require('../../models/service-provider');
|
||||
const uuidv4 = require('uuid/v4');
|
||||
const decorate = require('./decorate');
|
||||
const snakeCase = require('../../utils/snake-case');
|
||||
const sysError = require('./error');
|
||||
@@ -153,9 +154,8 @@ async function validateCreateMessage(logger, sid, req) {
|
||||
}
|
||||
|
||||
if (!obj.to) throw new DbErrorBadRequest('missing to property');
|
||||
//obj.to = typeof obj.to === 'string' ? [obj.to] : obj.to;
|
||||
|
||||
if (!obj.text && (!obj.media || 0 === obj.media.length)) {
|
||||
if (!obj.text && !obj.media) {
|
||||
throw new DbErrorBadRequest('either text or media required in outbound message');
|
||||
}
|
||||
}
|
||||
@@ -464,7 +464,7 @@ router.post('/:sid/Messages', async(req, res) => {
|
||||
const serviceUrl = `http://${ip}:3000/v1/createMessage/${sid}`;
|
||||
await validateCreateMessage(logger, sid, req);
|
||||
|
||||
const payload = req.body;
|
||||
const payload = Object.assign({messageSid: uuidv4()}, req.body);
|
||||
logger.debug({payload}, `sending createMessage API request to to ${ip}`);
|
||||
updateLastUsed(logger, sid, req).catch((err) => {});
|
||||
request({
|
||||
|
||||
@@ -20,7 +20,8 @@ api.use('/Sbcs', isAdminScope, require('./sbcs'));
|
||||
api.use('/Users', require('./users'));
|
||||
api.use('/login', require('./login'));
|
||||
|
||||
api.use('/messaging', require('./sms-inbound'));
|
||||
api.use('/outboundSMS', require('./sms-outbound'));
|
||||
// messaging
|
||||
api.use('/messaging', require('./sms-inbound')); // inbound SMS from carrier
|
||||
api.use('/outboundSMS', require('./sms-outbound')); // outbound SMS from feature server
|
||||
|
||||
module.exports = api;
|
||||
|
||||
@@ -1597,6 +1597,8 @@ paths:
|
||||
type: string
|
||||
format: uuid
|
||||
example: 2531329f-fb09-4ef7-887e-84e648214436
|
||||
providerResponse:
|
||||
type: string
|
||||
400:
|
||||
description: bad request
|
||||
components:
|
||||
@@ -1953,19 +1955,11 @@ components:
|
||||
from:
|
||||
type: string
|
||||
to:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
cc:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
text:
|
||||
type: string
|
||||
media:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
required:
|
||||
- from
|
||||
- to
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"dependencies": {
|
||||
"@jambonz/db-helpers": "^0.5.1",
|
||||
"@jambonz/messaging-382com": "0.0.2",
|
||||
"@jambonz/messaging-peerless": "0.0.6",
|
||||
"@jambonz/messaging-peerless": "0.0.9",
|
||||
"@jambonz/messaging-simwood": "0.0.4",
|
||||
"@jambonz/realtimedb-helpers": "0.2.17",
|
||||
"cors": "^2.8.5",
|
||||
|
||||
Reference in New Issue
Block a user