Skip to content

Commit 633e823

Browse files
authored
Merge pull request #503 from ModWorkshop/main
3.6.1
2 parents b7d1594 + 3f5dcd9 commit 633e823

File tree

13 files changed

+47
-48
lines changed

13 files changed

+47
-48
lines changed

backend/Dockerfile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
#syntax=docker/dockerfile:1
22
FROM dunglas/frankenphp:1.8.0-php8.3-bookworm AS build
33

4-
RUN apt-get update && apt-get install supervisor -y
4+
RUN apt-get update && apt-get install -y --no-install-recommends supervisor
55

66
# # Using heredoc from dockerfile:1.4 (ref: https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/)
77
# # PHP ini configuration
88
# # So php ini doesn't break
99
RUN install-php-extensions \
1010
apcu \
1111
ffi \
12-
simplexml \
13-
tokenizer \
14-
fileinfo \
1512
redis \
1613
pdo_mysql \
17-
pdo \
1814
exif \
1915
pdo_pgsql \
20-
xmlwriter \
2116
pcntl \
22-
posix \
2317
zip \
24-
vips \
25-
opcache
18+
vips
2619

2720
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
2821

@@ -60,7 +53,7 @@ COPY --chown=nobody . /app
6053
COPY conf.d/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
6154
COPY conf.d/Caddyfile /etc/caddy/Caddyfile
6255

63-
RUN apt-get update && apt-get install cron -y \
56+
RUN apt-get update && apt-get install -y --no-install-recommends cron \
6457
# && chown nobody:nogroup /usr/sbin/cron \
6558
# && setcap cap_setgid=ep /usr/sbin/cron \
6659
&& mkdir /etc/crontabs \

backend/app/Http/Controllers/AuditLogController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function index(FilteredRequest $request, ?Game $game=null)
2525
return AuditLogResource::collectionResponse(AuditLog::queryGet($val, function($query) use ($game) {
2626
if (isset($game)) {
2727
$query->where('game_id', $game->id);
28-
}
28+
}
2929
$query->orderBy('updated_at', 'desc');
3030
}));
3131
}
@@ -43,7 +43,6 @@ public function show(AuditLog $auditLog)
4343
*/
4444
public function destroy(AuditLog $auditLog)
4545
{
46-
\Log::info('hi');
4746
$auditLog->delete();
4847
}
4948
}

backend/app/Http/Controllers/BanController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function update(Request $request, Ban $ban)
121121
abort(403, 'Cannot edit ban of user since you cannot ban them normally.');
122122
}
123123

124-
AuditLog::logUpdate($ban, $val);
124+
AuditLog::logUpdate($ban, $val, objectUserAsContext: true);
125125

126126
$ban->update($val);
127127

@@ -145,7 +145,7 @@ public function show(Ban $ban)
145145
*/
146146
public function destroy(Ban $ban)
147147
{
148-
AuditLog::logDelete($ban);
148+
AuditLog::logDelete($ban, objectUserAsContext: true);
149149
$ban->delete();
150150
}
151151
}

backend/app/Http/Controllers/UserCaseController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @group User Cases
2222
* @authenticated
23-
*
23+
*
2424
* @hideFromApiDocumentation
2525
*/
2626
class UserCaseController extends Controller
@@ -83,7 +83,7 @@ public function store(Request $request, Game $game=null)
8383
$user = User::find($val['user_id']);
8484
$case = UserCase::create($val);
8585

86-
AuditLog::logCreate($case, $val);
86+
AuditLog::logCreate($case, $val, objectUserAsContext: true);
8787

8888
Notification::send(
8989
notifiable: $case,
@@ -118,7 +118,7 @@ public function update(Request $request, UserCase $userCase)
118118

119119
Utils::convertToUTC($val, 'expire_date');
120120

121-
AuditLog::logUpdate($userCase, $val);
121+
AuditLog::logUpdate($userCase, $val, objectUserAsContext: true);
122122

123123
$userCase->update($val);
124124

@@ -130,7 +130,7 @@ public function update(Request $request, UserCase $userCase)
130130
*/
131131
public function destroy(UserCase $userCase)
132132
{
133-
AuditLog::logDelete($userCase);
133+
AuditLog::logDelete($userCase, objectUserAsContext: true);
134134
$userCase->delete();
135135
}
136136
}

backend/app/Models/AuditLog.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Illuminate\Database\Eloquent\Casts\Attribute;
1111

1212
/**
13-
*
13+
*
1414
*
1515
* @property int $id
1616
* @property string $type
@@ -63,7 +63,7 @@ class AuditLog extends Model
6363
protected $guarded = [];
6464

6565
protected $with = ['context', 'auditable', 'user'];
66-
66+
6767
protected $casts = [
6868
'data' => 'array',
6969
];
@@ -72,12 +72,12 @@ public function user(): BelongsTo
7272
{
7373
return $this->belongsTo(User::class);
7474
}
75-
75+
7676
public function game(): BelongsTo
7777
{
7878
return $this->belongsTo(Game::class);
7979
}
80-
80+
8181
public function auditable(): BelongsTo
8282
{
8383
return $this->morphTo();
@@ -146,15 +146,16 @@ public static function log(
146146
return $log->save();
147147
}
148148

149-
public static function logCreate(Model $object, array $data = [], ?Game $game = null) {
149+
public static function logCreate(Model $object, array $data = [], ?Game $game = null, bool $objectUserAsContext=false) {
150150
return self::log(
151151
type:'create',
152152
auditable: $object,
153+
context: $objectUserAsContext ? $object->user : null,
153154
game: $game
154155
);
155156
}
156157

157-
public static function logUpdate(Model $object, array $data = [], ?Game $game = null) {
158+
public static function logUpdate(Model $object, array $data = [], ?Game $game = null, bool $objectUserAsContext=false) {
158159
$added = Arr::pull($data, '$added', []);
159160
$removed = Arr::pull($data, '$removed', []);
160161

@@ -172,7 +173,7 @@ public static function logUpdate(Model $object, array $data = [], ?Game $game =
172173

173174
foreach ($removed as $key => $arr) {
174175
foreach ($arr as $add) {
175-
$changes[] = [
176+
$changes[] = [
176177
'type' => 'remove',
177178
'key' => $key,
178179
'value_type' => $add->getMorphClass(),
@@ -183,7 +184,7 @@ public static function logUpdate(Model $object, array $data = [], ?Game $game =
183184

184185
foreach ($added as $key => $arr) {
185186
foreach ($arr as $add) {
186-
$changes[] = [
187+
$changes[] = [
187188
'type' => 'add',
188189
'key' => $key,
189190
'value_type' => $add->getMorphClass(),
@@ -216,16 +217,17 @@ public static function logUpdate(Model $object, array $data = [], ?Game $game =
216217
} else {
217218
return self::log(
218219
type: 'update',
219-
auditable: $object,
220+
auditable: $object,
221+
context: $objectUserAsContext ? $object->user : null,
220222
data: [
221223
'changes' => $changes
222-
],
224+
],
223225
game: $game
224226
);
225227
}
226228
}
227229

228-
public static function logDelete(Model $object, ?Game $game = null) {
230+
public static function logDelete(Model $object, ?Game $game = null, bool $objectUserAsContext=false) {
229231
$log = new AuditLog([
230232
'type' => 'delete',
231233
'auditable_name' => $object->name ?? $object->title,
@@ -240,7 +242,7 @@ public static function logDelete(Model $object, ?Game $game = null) {
240242
$log->game()->associate($game);
241243
}
242244

243-
if ($object->user) {
245+
if ($objectUserAsContext && $object->user) {
244246
$log->context()->associate($object->user);
245247
$log->context_name = $object->user->name;
246248
}

backend/app/Models/ModManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Eloquent\Relations\BelongsTo;
77

88
/**
9-
*
9+
*
1010
*
1111
* @property int $id
1212
* @property string $name
@@ -48,4 +48,8 @@ public function game(): BelongsTo
4848
public function games() {
4949
return $this->belongsToMany(Game::class);
5050
}
51+
52+
public function getMorphClass(): string {
53+
return 'mod_manager';
54+
}
5155
}

frontend/app/components/site/pages/admin/admin-audit-log.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</template>
1919
<template #auditable>
2020
<a-user v-if="log.auditable_type == 'user'" :user="log.auditable as User" :avatar="false"/>
21-
<span v-else-if="log.auditable_name || log.auditable">"{{ log.auditable_name ?? 'Unknown' }}"</span>
21+
<span v-else-if="log.auditable_name">"{{ log.auditable_name }}"</span>
2222
</template>
2323
<template #context_type>
2424
{{ pretty(log.context_type) }}
@@ -101,8 +101,8 @@ useI18n({
101101
en: {
102102
log_ban: '{user} banned {auditable} {custom}',
103103
log_delete: '{user} deleted {auditable_type} {auditable} {associated_context}',
104-
log_update: '{user} updated {auditable_type} {auditable}',
105-
log_create: '{user} created {auditable_type} {auditable}',
104+
log_update: '{user} updated {auditable_type} {auditable} {associated_context}',
105+
log_create: '{user} created {auditable_type} {auditable} {associated_context}',
106106
log_mod_approve_status: '{user} has {custom} {auditable}',
107107
log_mod_suspend_status: '{user} has {custom} {auditable}',
108108
log_category_mass_move_mods: '{user} moved {auditable} mods to {context}'

frontend/app/components/site/pages/the-footer.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<m-link to="/document/rules">{{ $t('rules') }}</m-link>
3131
</m-flex>
3232
<m-flex column gap="4" style="grid-area: sites;">
33+
<m-link to="https://github.com/ModWorkshop/site">{{ $t('repository') }}</m-link>
3334
<m-link to="https://translate.modworkshop.net/">{{ $t('translation_site') }}</m-link>
3435
<m-link to="https://status.modworkshop.net">{{ $t('status') }}</m-link>
3536
<m-link to="https://wiki.modworkshop.net/">{{ $t('wiki') }}</m-link>
@@ -54,10 +55,10 @@
5455
</m-flex>
5556
<m-flex class="sm:ml-auto text-2xl" gap="3">
5657
<m-link to="https://discord.gg/Eear4JW"><i-ri-discord-fill/></m-link>
58+
<m-link to="https://github.com/ModWorkshop"><i-ri-github-fill/></m-link>
5759
<m-link to="https://x.com/ModWorkshop"><i-ri-twitter-x-fill/></m-link>
5860
<m-link to="https://bsky.app/profile/modworkshop.bsky.social"><i-ri-bluesky-fill/></m-link>
5961
<m-link to="https://www.youtube.com/@modworkshop-yt"><i-ri-youtube-fill/></m-link>
60-
<m-link to="https://github.com/ModWorkshop"><i-ri-github-fill/></m-link>
6162
</m-flex>
6263
</m-flex>
6364
</m-flex>

frontend/app/components/ui/controls/m-select.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,12 @@ const emit = defineEmits<{
112112
(e: 'fetched', options: any[]): void;
113113
}>();
114114
115-
const { data: asyncOptions, refresh } = await useFetchMany(props.url ?? 'a', {
116-
immediate: props.immediateFetch && !!props.url,
115+
const { data: asyncOptions, refresh } = await useFetchMany(props.url ?? '', {
116+
immediate: props.immediateFetch && props.url != undefined,
117117
params: reactive({
118118
query: searchDebounced,
119119
...props.fetchParams
120-
}),
121-
cacheData: true
120+
})
122121
});
123122
124123
const selectedValue = computed(() => props.modelValue ?? props.default);
@@ -128,13 +127,12 @@ const { ctrl } = useMagicKeys();
128127
129128
// Only necessary to retrieve the v-model that may not be contained in asyncOptions
130129
// Example: user query parameter to prefill a user
131-
const { data: fetchedSelected } = await useFetchMany(props.url ?? 'a', {
130+
const { data: fetchedSelected } = await useFetchMany(props.url ?? '', {
132131
immediate: !!(props.url && first.value) && (typeof (first.value) == 'number' || first.value?.length > 0),
133132
params: {
134133
ids: selected.value,
135134
...props.fetchParams
136-
},
137-
cacheData: true
135+
}
138136
});
139137
140138
// The options of the select that are actually shown
@@ -143,8 +141,8 @@ const opts = computed(() => {
143141
if (props.options) {
144142
return props.options ?? [];
145143
} else {
146-
const opts = reactive(asyncOptions.value != null ? [...asyncOptions.value.data] : []);
147-
if (fetchedSelected.value != null && fetchedSelected.value.data) {
144+
const opts = reactive(asyncOptions.value != undefined ? [...asyncOptions.value.data] : []);
145+
if (fetchedSelected.value != undefined && fetchedSelected.value.data) {
148146
for (const opt of fetchedSelected.value.data) {
149147
const val = opt ? optionValue(opt) : null;
150148
if (!opts.find(option => optionValue(option) === val)) {

frontend/app/composables/useResource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { SearchParameters } from 'ofetch';
22
import { useI18n } from 'vue-i18n';
3+
import clone from 'rfdc/default';
34

45
/**
56
* Attempts to fetch a resoure based on name and URL, if the param doesn't exist, assumes the resources is optional
@@ -51,6 +52,6 @@ export default async function<T>(
5152

5253
return {
5354
...res,
54-
data: reactive(res.data)
55+
data: ref(clone(res.data.value as T)) as Ref<T>
5556
};
5657
}

0 commit comments

Comments
 (0)