Skip to content

Commit c13fb1a

Browse files
Merge pull request #7522 from christianbeeznest/fixes-updates258
Social: Improve social user loader to use explicit "uid" param
2 parents b428fbf + 083374e commit c13fb1a

3 files changed

Lines changed: 28 additions & 32 deletions

File tree

assets/vue/composables/useSocialInfo.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,24 @@ export function useSocialInfo() {
3434
groupInfo.value = {}
3535
isGroup.value = false
3636
}
37-
isLoading.value = false
3837
} else {
3938
isGroup.value = false
4039
groupInfo.value = {}
4140
}
41+
isLoading.value = false
4242
}
4343
const loadUser = async () => {
4444
try {
45-
if (route.query.id) {
45+
const uid = route.query.uid
46+
if (uid) {
4647
const params = { ...route.query }
48+
// Ensure id is never used even if present.
49+
delete params.id
50+
4751
if (route.path.includes("/social")) {
4852
params.page_origin = "social"
4953
}
50-
const response = await axios.get(`/api/users/${route.query.id}`, { params })
54+
const response = await axios.get(`/api/users/${uid}`, { params })
5155
user.value = response.data
5256
isCurrentUser.value = false
5357
} else {
@@ -61,9 +65,8 @@ export function useSocialInfo() {
6165
}
6266
onMounted(async () => {
6367
try {
64-
//if (!route.params.group_id) {
6568
await loadUser()
66-
//}
69+
6770
if (route.params.group_id) {
6871
await loadGroup(route.params.group_id)
6972
}

assets/vue/views/social/SocialWall.vue

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const wallUser = ref(null)
6969
provide("social-user", wallUser)
7070
7171
const wallIdFromRoute = computed(() => {
72-
const raw = route.query.id
72+
const raw = route.query.uid
7373
if (!raw) return null
7474
const n = Number(raw)
7575
return Number.isFinite(n) && n > 0 ? n : null
@@ -85,12 +85,12 @@ const wallName = computed(() => {
8585
const isWallLoading = computed(() => !isOwnWallByRoute.value && !wallName.value)
8686
8787
const wallTitle = computed(() => {
88-
if (isOwnWallByRoute.value) return ''
88+
if (isOwnWallByRoute.value) return ""
8989
if (isWallLoading.value) return `${t("Social wall")}`
9090
return `${t("Wall of {0}", [wallName.value])}`.trim()
9191
})
9292
93-
// Remount children when wall id or filter changes (prevents stale state reuse)
93+
// Remount children when wall id or filter changes
9494
const wallKey = computed(() => `wall:${wallIdFromRoute.value || "me"}:${filterType.value || "all"}`)
9595
9696
async function loadWallUser() {
@@ -105,7 +105,7 @@ async function loadWallUser() {
105105
return
106106
}
107107
108-
// Stub user to prevent null-access while loading.
108+
// Stub user to prevent null-access while loading
109109
wallUser.value = {
110110
id: targetId,
111111
"@id": `/api/users/${targetId}`,
@@ -132,15 +132,19 @@ async function hasFriendship(meIri, wallIri) {
132132
133133
try {
134134
const [a, b] = await Promise.all([
135-
axios.get(`${ENTRYPOINT}user_rel_users`, { params: { relationType: 3, user: meIri, friend: wallIri } }),
136-
axios.get(`${ENTRYPOINT}user_rel_users`, { params: { relationType: 3, user: wallIri, friend: meIri } }),
135+
axios.get(`${ENTRYPOINT}user_rel_users`, {
136+
params: { relationType: 3, user: meIri, friend: wallIri },
137+
}),
138+
axios.get(`${ENTRYPOINT}user_rel_users`, {
139+
params: { relationType: 3, user: wallIri, friend: meIri },
140+
}),
137141
])
138142
139143
const aCount = Array.isArray(a.data?.["hydra:member"]) ? a.data["hydra:member"].length : 0
140144
const bCount = Array.isArray(b.data?.["hydra:member"]) ? b.data["hydra:member"].length : 0
141145
return aCount + bCount > 0
142146
} catch (e) {
143-
console.warn("Friendship check failed; posting on other wall disabled.", e)
147+
console.warn("Friendship check failed; posting disabled.", e)
144148
return false
145149
}
146150
}
@@ -162,32 +166,18 @@ async function refreshOtherWallPermission() {
162166
return
163167
}
164168
165-
// Reset immediately so UI doesn't reuse previous wall permission
166169
canWriteOnOtherWall.value = null
167170
const allowed = await hasFriendship(meIri, wallIri)
168171
169-
// Ignore outdated results (race condition guard)
170-
if (seq !== permissionSeq) {
171-
console.debug("Ignoring outdated friendship result (race condition).")
172-
return
173-
}
172+
if (seq !== permissionSeq) return
173+
if (targetWallId !== wallIdFromRoute.value) return
174174
175-
// Also ensure we are still on the same wall
176-
if (targetWallId !== wallIdFromRoute.value) {
177-
console.debug("Ignoring friendship result: wall changed during request.")
178-
return
179-
}
180175
canWriteOnOtherWall.value = allowed
181176
}
182177
183-
watch(
184-
[() => currentUserIri.value, () => wallIdFromRoute.value],
185-
() => {
186-
canWriteOnOtherWall.value = isOwnWallByRoute.value ? null : null
187-
refreshOtherWallPermission()
188-
},
189-
{ immediate: true },
190-
)
178+
watch([() => currentUserIri.value, () => wallIdFromRoute.value], () => refreshOtherWallPermission(), {
179+
immediate: true,
180+
})
191181
192182
watch(
193183
() => route.query.filterType,
@@ -216,16 +206,19 @@ function refreshPosts() {
216206
217207
function filterMessages(type) {
218208
const nextQuery = { ...route.query }
209+
219210
if (type === null) {
220211
delete nextQuery.filterType
221212
} else {
222213
nextQuery.filterType = type
223214
}
215+
224216
router.push({ path: "/social", query: nextQuery })
225217
}
226218
227219
function tabClasses(type) {
228220
const isActive = type ? filterType.value === type : !filterType.value
221+
229222
return [
230223
"inline-flex items-center rounded-full border px-4 py-2 text-body-2 font-medium transition-colors duration-150",
231224
"focus:outline-none focus:ring-2 focus:ring-primary",

src/CoreBundle/Controller/SocialController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ public function search(
832832
'avatar' => $userRepository->getUserPicture($item['id']),
833833
'role' => 5 === $item['status'] ? 'student' : 'teacher',
834834
'status' => $isUserOnline ? 'online' : 'offline',
835-
'url' => '/social?id='.$item['id'],
835+
'url' => '/social?uid='.$item['id'],
836836
'relationType' => $relation['relationType'] ?? null,
837837
'existingInvitations' => $existingInvitations,
838838
];

0 commit comments

Comments
 (0)