This repository was archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhostile.js
More file actions
54 lines (47 loc) · 1.78 KB
/
Copy pathhostile.js
File metadata and controls
54 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var mongoose = require('mongoose-q')()
, Schema = mongoose.Schema
, moment = require('moment')
, key_generator = require(__dirname + '/../util/key-generator')
, System = require('./system')
, settings = require(__dirname + '/../config/settings')
var HostileSchema = new Schema({
ts: { type: Number, default: function() { return moment().unix(); } },
key: { type: String, default: function() { return key_generator.getKey(); } },
fleetKey: { type: String },
characterId: Number,
characterName: String,
corporationId: Number,
corporationName: String,
allianceId: Number,
allianceName: String,
shipType: String,
shipTypeId: Number,
shipName: String,
systemId: Number,
systemName: String,
reporterId: Number,
reporterName: String,
is_faded: { type: Boolean, default: false },
is_docked: { type: Boolean, default: false }
});
HostileSchema.index({ ts: 1, key: 1, fleetKey: 1 }, { expireAfterSeconds: settings.hostileRemoveTtl });
HostileSchema.statics.prepare = function prepare(fleetKey, reporter, hostile) {
return new this({
ts: moment().unix(),
key: hostile.key || key_generator.getKey(),
fleetKey: fleetKey,
reporterId: reporter.characterId || reporter.characterID,
reporterName: reporter.characterName,
characterId: hostile.characterId || hostile.characterID,
characterName: hostile.characterName,
corporationId: hostile.corporationID,
corporationName: hostile.corporationName,
allianceId: hostile.allianceID,
allianceName: hostile.allianceName,
shipType: hostile.shipType,
shipTypeId: hostile.shipTypeId,
is_faded: false,
is_docked: hostile.is_docked || false
}, { versionKey: false });
};
module.exports = mongoose.model('Hostile', HostileSchema);