feat(sharkey): no-remote-users.patch
This commit is contained in:
parent
eeb53df81f
commit
3855fef54b
2 changed files with 72 additions and 0 deletions
|
@ -38,6 +38,7 @@ RUN git apply /patches/unfollow-notification.patch
|
||||||
RUN git apply /patches/webhook-notification.patch
|
RUN git apply /patches/webhook-notification.patch
|
||||||
# motivation: https://very.stupid.fish/notes/9shhrn2qncid008s
|
# motivation: https://very.stupid.fish/notes/9shhrn2qncid008s
|
||||||
RUN git apply /patches/index-everything.patch
|
RUN git apply /patches/index-everything.patch
|
||||||
|
RUN git apply /patches/no-remote-users.patch
|
||||||
RUN cp -f /patches/robots.txt packages/backend/assets/robots.txt
|
RUN cp -f /patches/robots.txt packages/backend/assets/robots.txt
|
||||||
# end patch
|
# end patch
|
||||||
|
|
||||||
|
|
71
hosts/koi/containers/sharkey/patches/no-remote-users.patch
Normal file
71
hosts/koi/containers/sharkey/patches/no-remote-users.patch
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts
|
||||||
|
index bd81989..8aaf8ca 100644
|
||||||
|
--- a/packages/backend/src/server/api/endpoints/users/show.ts
|
||||||
|
+++ b/packages/backend/src/server/api/endpoints/users/show.ts
|
||||||
|
@@ -97,6 +97,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
const isModerator = await this.roleService.isModerator(me);
|
||||||
|
ps.username = ps.username?.trim();
|
||||||
|
|
||||||
|
+ const authed = me !== null
|
||||||
|
+
|
||||||
|
if (ps.userIds) {
|
||||||
|
if (ps.userIds.length === 0) {
|
||||||
|
return [];
|
||||||
|
@@ -112,7 +114,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
// リクエストされた通りに並べ替え
|
||||||
|
const _users: MiUser[] = [];
|
||||||
|
for (const id of ps.userIds) {
|
||||||
|
- _users.push(users.find(x => x.id === id)!);
|
||||||
|
+ const user = users.find(x => x.id === id)
|
||||||
|
+ if (user && (authed || user.host === null)) {
|
||||||
|
+ _users.push(user);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
return await Promise.all(_users.map(u => this.userEntityService.pack(u, me, {
|
||||||
|
@@ -137,6 +142,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (!authed && user.host !== null) {
|
||||||
|
+ throw new ApiError({
|
||||||
|
+ code: 'X_REMOTE_REDIRECT',
|
||||||
|
+ message: 'Redirect to remote user',
|
||||||
|
+ id: 'X_REMOTE_REDIRECT',
|
||||||
|
+ }, user.uri);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (user.host == null) {
|
||||||
|
if (me == null && ip != null) {
|
||||||
|
this.perUserPvChart.commitByVisitor(user, ip);
|
||||||
|
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
|
||||||
|
index cb41c4f..8199e3c 100644
|
||||||
|
--- a/packages/backend/src/server/web/ClientServerService.ts
|
||||||
|
+++ b/packages/backend/src/server/web/ClientServerService.ts
|
||||||
|
@@ -526,6 +526,11 @@ export class ClientServerService {
|
||||||
|
|
||||||
|
if (user != null) {
|
||||||
|
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
|
||||||
|
+ if (user.host !== null) {
|
||||||
|
+ reply.redirect(301, profile.url);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
const meta = await this.metaService.fetch();
|
||||||
|
const me = profile.fields
|
||||||
|
? profile.fields
|
||||||
|
diff --git a/packages/frontend/src/pages/user/index.vue b/packages/frontend/src/pages/user/index.vue
|
||||||
|
index ebe4176..0cd39f3 100644
|
||||||
|
--- a/packages/frontend/src/pages/user/index.vue
|
||||||
|
+++ b/packages/frontend/src/pages/user/index.vue
|
||||||
|
@@ -70,6 +70,10 @@ function fetchUser(): void {
|
||||||
|
misskeyApi('users/show', Misskey.acct.parse(props.acct)).then(u => {
|
||||||
|
user.value = u;
|
||||||
|
}).catch(err => {
|
||||||
|
+ if (err.code === 'X_REMOTE_REDIRECT') {
|
||||||
|
+ location.replace(err.info);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
error.value = err;
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue