Skip to content

Commit

Permalink
feat(vzor): imap listen
Browse files Browse the repository at this point in the history
  • Loading branch information
qertis committed Dec 3, 2019
1 parent 732bfef commit b0ca6bf
Show file tree
Hide file tree
Showing 26 changed files with 528 additions and 197 deletions.
10 changes: 10 additions & 0 deletions SQL/linked-data/tables/ld.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE SCHEMA data;

CREATE TABLE IF NOT EXISTS data.ld (
id BIGSERIAL,
jsonld JSONB NOT NULL, -- JSONLD данные которые можно превратить в n-quads
created_at TIMESTAMP DEFAULT current_timestamp,
PRIMARY KEY (id)
);

GRANT ALL PRIVILEGES ON data.ld TO bot;
2 changes: 0 additions & 2 deletions SQL/messages/schemas/create_schemes.sql

This file was deleted.

36 changes: 0 additions & 36 deletions SQL/messages/tables/abstract.sql

This file was deleted.

Empty file removed SQL/messages/tables/concrete.sql
Empty file.
8 changes: 0 additions & 8 deletions SQL/passports/tables/ld.sql

This file was deleted.

9 changes: 0 additions & 9 deletions SQL/passports/views/sessions.sql

This file was deleted.

159 changes: 153 additions & 6 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@
"operationId": "ping.js",
"deprecated": false,
"summary": "/ping",
"description": "проверка ping",
"description": "Проверка ping",
"tags": [
"JSONRPC"
],
Expand Down Expand Up @@ -849,6 +849,83 @@
}
}
},
"/api/read": {
"post": {
"operationId": "read.js",
"deprecated": false,
"summary": "/read",
"description": "Чтение письма и запись в БД",
"tags": [
"JSONRPC"
],
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"method",
"id",
"jsonrpc",
"params"
],
"properties": {
"method": {
"type": "string",
"default": "read",
"description": "API method read"
},
"id": {
"type": "integer",
"default": 1,
"format": "int32",
"description": "Request ID"
},
"jsonrpc": {
"type": "string",
"default": "2.0",
"description": "JSON-RPC Version (2.0)"
},
"params": {
"title": "Parameters",
"type": "object",
"required": [
"method",
"id",
"jsonrpc"
],
"properties": {}
}
}
}
}
}
}
}
},
"/api/remove": {
"post": {
"operationId": "remove.js",
Expand Down Expand Up @@ -1080,23 +1157,84 @@
}
}
},
"/": {
"get": {
"/api/text": {
"post": {
"operationId": "text.js",
"deprecated": false,
"summary": "/text",
"description": "Генерация сообщения для почты",
"tags": [
"JSONRPC"
],
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"application/json": {
"schema": {
"type": "string"
"type": "object"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"method",
"id",
"jsonrpc",
"params"
],
"properties": {
"method": {
"type": "string",
"default": "text",
"description": "API method text"
},
"id": {
"type": "integer",
"default": 1,
"format": "int32",
"description": "Request ID"
},
"jsonrpc": {
"type": "string",
"default": "2.0",
"description": "JSON-RPC Version (2.0)"
},
"params": {
"title": "Parameters",
"type": "object",
"required": [
"method",
"id",
"jsonrpc"
],
"properties": {}
}
}
}
}
}
}
}
},
"/oauth": {
"/": {
"get": {
"responses": {
"200": {
Expand All @@ -1111,6 +1249,15 @@
}
}
}
},
"/oauth/*": {
"get": {
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
Expand Down
9 changes: 9 additions & 0 deletions scripts/api-generate
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ const { SERVER } = require('../src/environment');
// ...
// todo /bot
// ...
data.paths['/oauth/*'] = {
get: {
responses: {
'200': {
description: 'OK',
},
},
},
};
fs.writeFileSync('docs/openapi.json', JSON.stringify(data, null, 2));
})();
1 change: 1 addition & 0 deletions scripts/index
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const clipboardHelper = require('../src/helpers/clipboard');
throw new Error('Please use `node src/server`');
} else {
await ngrok.authtoken(NGROK.TOKEN);
await ngrok.disconnect();
let nodemonInstance;
try {
const url = await ngrok.connect({
Expand Down
5 changes: 5 additions & 0 deletions src/api/v3/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const twoFactorAuthService = require('../../services/2fa.service');
const oauthService = require('../../services/oauth.service');
const passportQueries = require('../../db/passport');
const botQueries = require('../../db/bot');
const ldQueries = require('../../db/ld');
/**
* @description Регистрация письма
* @param {*} transactionConnection - transactionConnection
* @param {string} passportId - passport guid
* @param {Array<string>} passportEmail - passport email
Expand Down Expand Up @@ -143,8 +145,11 @@ const createPassport = async (
if (telegram.from) {
tgData = telegram.from;
}
// todo нужно устанавливать минимально рабочий json-ld
const linkedData = await transactionConnection.one(ldQueries.createLD({}));
const passport = await transactionConnection.one(
passportQueries.createPassport({
ld_id: linkedData.id,
telegramPassport: tgData,
facebookPassport: fbData,
yandexPassport: yaData,
Expand Down
Loading

0 comments on commit b0ca6bf

Please sign in to comment.