File tree Expand file tree Collapse file tree 8 files changed +367
-14
lines changed
apps/juxtaposition-ui/src Expand file tree Collapse file tree 8 files changed +367
-14
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const { NOTIFICATION } = require('@/models/notifications');
88const { POST } = require ( '@/models/post' ) ;
99const { SETTINGS } = require ( '@/models/settings' ) ;
1010const { REPORT } = require ( '@/models/report' ) ;
11+ const { LOGS } = require ( '@/models/logs' ) ;
1112const { logger } = require ( '@/logger' ) ;
1213const { config } = require ( '@/config' ) ;
1314
@@ -506,6 +507,11 @@ async function getReportById(id) {
506507 return REPORT . findById ( id ) ;
507508}
508509
510+ async function getLogsForTarget ( targetPID , offset , limit ) {
511+ verifyConnected ( ) ;
512+ return LOGS . find ( { target : targetPID } ) . sort ( { timestamp : - 1 } ) . skip ( offset ) . limit ( limit ) ;
513+ }
514+
509515module . exports = {
510516 connect,
511517 getCommunities,
@@ -563,5 +569,6 @@ module.exports = {
563569 getReportsByOffender,
564570 getReportsByPost,
565571 getDuplicateReports,
566- getReportById
572+ getReportById,
573+ getLogsForTarget
567574} ;
Original file line number Diff line number Diff line change 1+ const { Schema, model } = require ( 'mongoose' ) ;
2+
3+ const actionEnum = [
4+ 'REMOVE_POST' ,
5+ 'IGNORE_REPORT' ,
6+ 'LIMIT_POSTING' ,
7+ 'TEMP_BAN' ,
8+ 'PERMA_BAN' ,
9+ 'UNBAN' ,
10+ 'UPDATE_USER' ,
11+ 'MAKE_COMMUNITY' ,
12+ 'UPDATE_COMMUNITY' ,
13+ 'DELETE_COMMUNITY'
14+ ] ;
15+
16+ const auditLogSchema = new Schema ( {
17+ actor : {
18+ type : Number ,
19+ required : true
20+ } ,
21+ action : {
22+ type : String ,
23+ enum : actionEnum ,
24+ required : true
25+ } ,
26+ target : {
27+ type : String ,
28+ required : true
29+ } ,
30+ context : {
31+ type : String ,
32+ required : true
33+ } ,
34+ timestamp : {
35+ type : Date ,
36+ default : Date . now ,
37+ required : true
38+ } ,
39+ changed_fields : {
40+ type : [ String ] ,
41+ default : [ ] ,
42+ required : true
43+ }
44+ } ) ;
45+
46+ const LOGS = model ( 'LOGS' , auditLogSchema ) ;
47+
48+ module . exports = {
49+ auditLogSchema,
50+ LOGS
51+ } ;
You can’t perform that action at this time.
0 commit comments