Browse Source

reload all timers on restart relay

hosting-provider
Evan Feenstra 5 years ago
parent
commit
647556ea9c
  1. 4
      api/controllers/index.ts
  2. 1
      api/network/receive.ts
  3. 1
      api/utils/timers.ts
  4. 2
      dist/api/controllers/index.js
  5. 2
      dist/api/controllers/index.js.map
  6. 1
      dist/api/network/receive.js
  7. 2
      dist/api/network/receive.js.map
  8. 1
      dist/api/utils/timers.js
  9. 2
      dist/api/utils/timers.js.map

4
api/controllers/index.ts

@ -13,6 +13,8 @@ import * as uploads from './uploads'
import * as confirmations from './confirmations' import * as confirmations from './confirmations'
import {checkTag} from '../utils/gitinfo' import {checkTag} from '../utils/gitinfo'
import * as path from 'path' import * as path from 'path'
import * as timers from '../utils/timers'
const env = process.env.NODE_ENV || 'development'; const env = process.env.NODE_ENV || 'development';
console.log("=> env:",env) console.log("=> env:",env)
@ -29,6 +31,8 @@ async function set(app) {
console.log('=> could not auth with media server', e.message) console.log('=> could not auth with media server', e.message)
} }
timers.reloadTimers()
app.get('/chats', chats.getChats) app.get('/chats', chats.getChats)
app.post('/group', chats.createGroupChat) app.post('/group', chats.createGroupChat)
app.post('/chats/:chat_id/:mute_unmute', chats.mute) app.post('/chats/:chat_id/:mute_unmute', chats.mute)

1
api/network/receive.ts

@ -55,7 +55,6 @@ async function onReceive(payload){
if(needsPricePerJoin) { if(needsPricePerJoin) {
if(payload.message.amount<chat.pricePerMessage) doAction=false if(payload.message.amount<chat.pricePerMessage) doAction=false
if(chat.escrowAmount) { if(chat.escrowAmount) {
console.log("ADD TIMEr",payload.message)
timers.addTimer({ // pay them back timers.addTimer({ // pay them back
amount: chat.escrowAmount, amount: chat.escrowAmount,
millis:chat.escrowMillis, millis:chat.escrowMillis,

1
api/utils/timers.ts

@ -29,7 +29,6 @@ export async function reloadTimers(){
}) })
} }
export async function payBack(t){ export async function payBack(t){
console.log("PAY BACK",t.dataValues)
const chat = await models.Chat.findOne({ where: {id:t.chatId} }) const chat = await models.Chat.findOne({ where: {id:t.chatId} })
const owner = await models.Contact.findOne({ where: {isOwner:true} }) const owner = await models.Contact.findOne({ where: {isOwner:true} })
if(!chat) return if(!chat) return

2
dist/api/controllers/index.js

@ -24,6 +24,7 @@ const uploads = require("./uploads");
const confirmations = require("./confirmations"); const confirmations = require("./confirmations");
const gitinfo_1 = require("../utils/gitinfo"); const gitinfo_1 = require("../utils/gitinfo");
const path = require("path"); const path = require("path");
const timers = require("../utils/timers");
const env = process.env.NODE_ENV || 'development'; const env = process.env.NODE_ENV || 'development';
console.log("=> env:", env); console.log("=> env:", env);
const constants = require(path.join(__dirname, '../../config/constants.json')); const constants = require(path.join(__dirname, '../../config/constants.json'));
@ -38,6 +39,7 @@ function set(app) {
catch (e) { catch (e) {
console.log('=> could not auth with media server', e.message); console.log('=> could not auth with media server', e.message);
} }
timers.reloadTimers();
app.get('/chats', chats.getChats); app.get('/chats', chats.getChats);
app.post('/group', chats.createGroupChat); app.post('/group', chats.createGroupChat);
app.post('/chats/:chat_id/:mute_unmute', chats.mute); app.post('/chats/:chat_id/:mute_unmute', chats.mute);

2
dist/api/controllers/index.js.map

File diff suppressed because one or more lines are too long

1
dist/api/network/receive.js

@ -68,7 +68,6 @@ function onReceive(payload) {
if (payload.message.amount < chat.pricePerMessage) if (payload.message.amount < chat.pricePerMessage)
doAction = false; doAction = false;
if (chat.escrowAmount) { if (chat.escrowAmount) {
console.log("ADD TIMEr", payload.message);
timers.addTimer({ timers.addTimer({
amount: chat.escrowAmount, amount: chat.escrowAmount,
millis: chat.escrowMillis, millis: chat.escrowMillis,

2
dist/api/network/receive.js.map

File diff suppressed because one or more lines are too long

1
dist/api/utils/timers.js

@ -48,7 +48,6 @@ function reloadTimers() {
exports.reloadTimers = reloadTimers; exports.reloadTimers = reloadTimers;
function payBack(t) { function payBack(t) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log("PAY BACK", t.dataValues);
const chat = yield models_1.models.Chat.findOne({ where: { id: t.chatId } }); const chat = yield models_1.models.Chat.findOne({ where: { id: t.chatId } });
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
if (!chat) if (!chat)

2
dist/api/utils/timers.js.map

@ -1 +1 @@
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../../../api/utils/timers.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAkC;AAClC,sCAAqC;AACrC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E,SAAsB,QAAQ,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAC;;QACpE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,GAAG,GAAG,MAAM,CAAA;QACzB,MAAM,CAAC,GAAG,MAAM,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAChC,MAAM,EAAE,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM;SAC/C,CAAC,CAAA;QACF,QAAQ,CAAC,IAAI,EAAE,GAAQ,EAAE;YACrB,OAAO,CAAC,CAAC,CAAC,CAAA;QACd,CAAC,CAAA,CAAC,CAAA;IACN,CAAC;CAAA;AATD,4BASC;AACD,SAAgB,QAAQ,CAAC,IAAW,EAAE,EAAE;IACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAChC,MAAM,EAAE,GAAG,IAAI,GAAC,GAAG,CAAA;IACnB,IAAG,EAAE,GAAC,CAAC;QAAE,EAAE,EAAE,CAAA,CAAC,wCAAwC;;QACjD,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AACxB,CAAC;AALD,4BAKC;AACD,SAAsB,YAAY;;QACjC,MAAM,MAAM,GAAG,MAAM,e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