bitcore-wallet-service/lib/model/notification.js

49 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-02-11 11:03:26 -08:00
var Uuid = require('uuid');
/*
* notifications examples
*
2015-02-11 18:11:30 -08:00
* NewCopayer -
* NewAddress -
* NewTxProposal - (amount)
* TxProposalAcceptedBy - (txProposalId, copayerId)
* TxProposalRejectedBy - (txProposalId, copayerId)
* txProposalFinallyRejected - txProposalId
* txProposalFinallyAccepted - txProposalId
*
* newIncommingTx (amount)
* newOutgoingTx - (txProposalId, txid)
2015-02-11 11:03:26 -08:00
*
* data Examples:
* { amount: 'xxx', address: 'xxx'}
* { txProposalId: 'xxx', copayerId: 'xxx' }
2015-02-11 18:11:30 -08:00
*
* Data is meant to provide only the needed information
* to notify the user
*
2015-02-11 11:03:26 -08:00
*/
function Notification(opts) {
opts = opts || {};
2015-02-12 05:26:13 -08:00
var now = Date.now();
this.createdOn = Math.floor(now / 1000);
this.id = ('00000000000000' + now).slice(-14) + ('0000' + opts.ticker||0).slice(-4) ;
2015-02-11 11:03:26 -08:00
this.type = opts.type || 'general';
this.data = opts.data;
};
2015-02-12 05:26:13 -08:00
Notification.fromObj = function(obj) {
2015-02-11 11:03:26 -08:00
var x= new Notification();
x.createdOn = obj.createdOn;
x.type = obj.type,
2015-02-12 05:26:13 -08:00
x.data = obj.data;
2015-02-11 11:03:26 -08:00
return x;
};
2015-02-11 18:11:30 -08:00
module.exports = Notification;