@@ -89,6 +89,13 @@ public ThreatConfiguration fetchThreatConfiguration(String accountId) {
8989 if (rateLimitConfig != null ) {
9090 builder .setRatelimitConfig (rateLimitConfig );
9191 }
92+
93+ // Handle archivalDays
94+ Object archivalDaysObj = doc .get ("archivalDays" );
95+ if (archivalDaysObj instanceof Number ) {
96+ int archivalDays = ((Number ) archivalDaysObj ).intValue ();
97+ builder .setArchivalDays (archivalDays );
98+ }
9299 }
93100 return builder .build ();
94101}
@@ -122,6 +129,11 @@ public ThreatConfiguration modifyThreatConfiguration(String accountId, ThreatCon
122129 }
123130 }
124131
132+ // Handle archivalDays
133+ if (updatedConfig .getArchivalDays () > 0 ) {
134+ newDoc .append ("archivalDays" , updatedConfig .getArchivalDays ());
135+ }
136+
125137 Document existingDoc = coll .find ().first ();
126138
127139 if (existingDoc != null ) {
@@ -131,13 +143,22 @@ public ThreatConfiguration modifyThreatConfiguration(String accountId, ThreatCon
131143 coll .insertOne (newDoc );
132144 }
133145
134- // Set the actor and ratelimitConfig in the returned proto
146+ // Set the actor, ratelimitConfig, and archivalDays in the returned proto
135147 if (updatedConfig .hasActor ()) {
136148 builder .setActor (updatedConfig .getActor ());
137149 }
138150 if (updatedConfig .hasRatelimitConfig ()) {
139151 builder .setRatelimitConfig (updatedConfig .getRatelimitConfig ());
140152 }
153+ // Read archivalDays from the saved document to return the current value
154+ Document savedDoc = coll .find ().first ();
155+ if (savedDoc != null ) {
156+ Object archivalDaysObj = savedDoc .get ("archivalDays" );
157+ if (archivalDaysObj instanceof Number ) {
158+ int archivalDays = ((Number ) archivalDaysObj ).intValue ();
159+ builder .setArchivalDays (archivalDays );
160+ }
161+ }
141162 return builder .build ();
142163}
143164
0 commit comments