diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-04 20:59:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-04 21:05:13 +0100 |
commit | 55fa55a9be566cca2ba95322f2ae23b434aed62a (patch) | |
tree | f51ef35c120ce8a928917a659418079538cdb8dc /server/models/request-to-pod.js | |
parent | a6fd2b30bf717eec14972a2175354781f5f43e77 (diff) | |
download | PeerTube-55fa55a9be566cca2ba95322f2ae23b434aed62a.tar.gz PeerTube-55fa55a9be566cca2ba95322f2ae23b434aed62a.tar.zst PeerTube-55fa55a9be566cca2ba95322f2ae23b434aed62a.zip |
Server: add video abuse support
Diffstat (limited to 'server/models/request-to-pod.js')
-rw-r--r-- | server/models/request-to-pod.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/server/models/request-to-pod.js b/server/models/request-to-pod.js new file mode 100644 index 000000000..f42a53458 --- /dev/null +++ b/server/models/request-to-pod.js | |||
@@ -0,0 +1,42 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | // --------------------------------------------------------------------------- | ||
4 | |||
5 | module.exports = function (sequelize, DataTypes) { | ||
6 | const RequestToPod = sequelize.define('RequestToPod', {}, { | ||
7 | indexes: [ | ||
8 | { | ||
9 | fields: [ 'requestId' ] | ||
10 | }, | ||
11 | { | ||
12 | fields: [ 'podId' ] | ||
13 | }, | ||
14 | { | ||
15 | fields: [ 'requestId', 'podId' ], | ||
16 | unique: true | ||
17 | } | ||
18 | ], | ||
19 | classMethods: { | ||
20 | removePodOf | ||
21 | } | ||
22 | }) | ||
23 | |||
24 | return RequestToPod | ||
25 | } | ||
26 | |||
27 | // --------------------------------------------------------------------------- | ||
28 | |||
29 | function removePodOf (requestsIds, podId, callback) { | ||
30 | if (!callback) callback = function () {} | ||
31 | |||
32 | const query = { | ||
33 | where: { | ||
34 | requestId: { | ||
35 | $in: requestsIds | ||
36 | }, | ||
37 | podId: podId | ||
38 | } | ||
39 | } | ||
40 | |||
41 | this.destroy(query).asCallback(callback) | ||
42 | } | ||