Instagram Microservice Update
This commit is contained in:
1 parent
ec52ee2c2a
commit
bb97677d39
10 files changed
+38
-24
No files matched your search
@@ -11,7 +11,7 @@ export default class App extends React.Component{
|
||||
<h1>Панель управления инстаграмом художки</h1>
|
||||
<p>Чтобы управлять, вы должны быть <a href="https://instagram.com/hudozka">hudozka</a></p>
|
||||
|
||||
<a href="/auth" onClick={this.handleClick.bind(this)}>Войти</a>
|
||||
<a href="auth" onClick={this.handleClick.bind(this)}>Войти</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,13 +12,19 @@ let privateData = JSON.parse(
|
||||
readFileSync(privatePath, 'utf-8')
|
||||
);
|
||||
|
||||
export const staticPath = path.join(
|
||||
__dirname,
|
||||
'../build'
|
||||
);
|
||||
|
||||
export const port = isProduction ? 18000 : 3000;
|
||||
// export const pathPrefix = isProduction ? '/service/instagram' : '';
|
||||
export const pathPrefix = '';
|
||||
export const pathPrefix = isProduction ? '/service/instagram' : '';
|
||||
export const baseHref = isProduction ? '/service/instagram/' : '/';
|
||||
// export const pathPrefix = '';
|
||||
export const indexPath = path.join(
|
||||
__dirname,
|
||||
'./templates/index.html'
|
||||
// '../build/main.html'
|
||||
// './templates/index.html'
|
||||
'../build/main.html'
|
||||
);
|
||||
// export const indexPath = '../build/main.html';
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ export async function updateSubscription(callbackUrl) {
|
||||
let data = await instagram.subscriptions.list();
|
||||
let activeSubscriptions = data.result;
|
||||
|
||||
console.log(`Active subscriptions ${activeSubscriptions}`);
|
||||
|
||||
let objectSubscriptions = activeSubscriptions.filter(i => i.object === 'user' && !i.object_id && i.callback_url === callbackUrl)
|
||||
|
||||
if (!objectSubscriptions.length) {
|
||||
|
||||
@@ -25,7 +25,6 @@ function main(){
|
||||
}
|
||||
|
||||
await clearSubscriptions();
|
||||
|
||||
await updateSubscription(updateSubscriptionCallbackUrl);
|
||||
repeat(updateSubscriptionDelay)(() => {
|
||||
updateSubscription(updateSubscriptionCallbackUrl);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'mz/fs';
|
||||
import compose from 'koa-compose';
|
||||
import route from 'koa-route';
|
||||
import {indexPath, pathPrefix as root} from '../config';
|
||||
import {indexPath, pathPrefix} from '../config';
|
||||
|
||||
import main from './main';
|
||||
import {auth, authCallback, authOut} from './auth';
|
||||
@@ -18,7 +18,7 @@ export function statelessRouters() {
|
||||
|
||||
export function routers() {
|
||||
return compose([
|
||||
main(),
|
||||
// main(),
|
||||
auth(),
|
||||
authCallback(),
|
||||
authOut(),
|
||||
@@ -29,10 +29,10 @@ export function routers() {
|
||||
]);
|
||||
}
|
||||
|
||||
export const url = path => `${root}${path}`;
|
||||
export const url = (path, root=pathPrefix) => `${root}${path}`;
|
||||
// export const url = path => path;
|
||||
export const get = (path, fn) => route['get'](url(path), fn);
|
||||
export const post = (path, fn) => route['post'](url(path), fn);
|
||||
export const get = (path, fn) => route['get'](url(path, ''), fn);
|
||||
export const post = (path, fn) => route['post'](url(path, ''), fn);
|
||||
|
||||
export function index(fn){
|
||||
return async (ctx) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Koa from 'koa';
|
||||
import mount from 'koa-mount';
|
||||
import serve from 'koa-static';
|
||||
import logger from 'koa-logger';
|
||||
import convert from 'koa-convert';
|
||||
import sessionStore from 'koa-session-store';
|
||||
import store from 'koa-session-mongo';
|
||||
@@ -9,14 +10,15 @@ import bodyParser from 'koa-bodyparser';
|
||||
import {db} from './core/db';
|
||||
import instagram from './middlewares/instagram';
|
||||
import {routers, statelessRouters} from './routers';
|
||||
import {pathPrefix, sessionSecret, sessionExpirationTime} from './config';
|
||||
import {pathPrefix, staticPath, sessionSecret, sessionExpirationTime} from './config';
|
||||
|
||||
export default function(){
|
||||
const app = new Koa();
|
||||
app.proxy = true;
|
||||
app.keys = [sessionSecret];
|
||||
|
||||
app.use(convert(serve('../build')));
|
||||
app.use(logger());
|
||||
app.use(serve(staticPath));
|
||||
app.use(bodyParser());
|
||||
app.use(statelessRouters());
|
||||
app.use(session('sid', sessionExpirationTime));
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Instagram Control</title>
|
||||
<base href="<%= htmlWebpackPlugin.options.baseHref %>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-container"></div>
|
||||
Reference in new issue
Block a user