浏览代码

Update DM config, allow new users to send DMs by default, with a new env variable to enforce a 72h limit

Daniel Supernault 3 月之前
父节点
当前提交
717f17cdee
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 3 1
      app/Http/Controllers/DirectMessageController.php
  2. 2 0
      config/instance.php

+ 3 - 1
app/Http/Controllers/DirectMessageController.php

@@ -144,7 +144,9 @@ class DirectMessageController extends Controller
         $user = $request->user();
         $user = $request->user();
         abort_if($user->has_roles && ! UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
         abort_if($user->has_roles && ! UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
         if (! $user->is_admin) {
         if (! $user->is_admin) {
-            abort_if($user->created_at->gt(now()->subHours(72)), 400, 'You need to wait a bit before you can DM another account');
+            if ((bool) ! config_cache('instance.allow_new_account_dms')) {
+                abort_if($user->created_at->gt(now()->subHours(72)), 400, 'You need to wait a bit before you can DM another account');
+            }
         }
         }
         $profile = $user->profile;
         $profile = $user->profile;
         $recipient = Profile::where('id', '!=', $profile->id)->findOrFail($request->input('to_id'));
         $recipient = Profile::where('id', '!=', $profile->id)->findOrFail($request->input('to_id'));

+ 2 - 0
config/instance.php

@@ -186,4 +186,6 @@ return [
     ],
     ],
 
 
     'show_peers' => env('INSTANCE_SHOW_PEERS', false),
     'show_peers' => env('INSTANCE_SHOW_PEERS', false),
+
+    'allow_new_account_dms' => env('INSTANCE_ALLOW_NEW_DMS', true),
 ];
 ];