Skip to content

Commit

Permalink
Merge branch 'develop' of https://git.joinsharkey.org/Sharkey/Sharkey
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
丈槍由紀 committed Dec 9, 2023
2 parents a428df7 + 1c05437 commit 00c85de
Show file tree
Hide file tree
Showing 36 changed files with 299 additions and 111 deletions.
10 changes: 10 additions & 0 deletions .forgejo/ISSUE_TEMPLATE/02_feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: "Feature Request"
about: "Suggest an idea for this project"
title: "feat: "
---
## Summary
<!-- Tell us what the suggestion is -->

## Purpose
<!-- Describe the specific problem or need you think this feature will solve, and who it will help. -->
24 changes: 24 additions & 0 deletions .forgejo/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- ℹ お読みください / README
PRありがとうございます! PRを作成する前に、コントリビューションガイドをご確認ください:
Thank you for your PR! Before creating a PR, please check the contribution guide:
https://github.com/misskey-dev/misskey/blob/develop/CONTRIBUTING.md
-->

## What
<!-- このPRで何をしたのか? どう変わるのか? -->
<!-- What did you do with this PR? How will it change things? -->

## Why
<!-- なぜそうするのか? どういう意図なのか? 何が困っているのか? -->
<!-- Why do you do it? What are your intentions? What is the problem? -->

## Additional info (optional)
<!-- テスト観点など -->
<!-- Test perspective, etc -->

## Checklist
- [ ] Read the [contribution guide](https://github.com/misskey-dev/misskey/blob/develop/CONTRIBUTING.md)
- [ ] Test working in a local environment
- [ ] (If needed) Add story of storybook
- [ ] (If needed) Update CHANGELOG.md
- [ ] (If possible) Add tests
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Setup Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python-version }}

Expand Down
123 changes: 42 additions & 81 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,101 +1,62 @@
# syntax = docker/dockerfile:1.4

ARG NODE_VERSION=20.5.1-bullseye
ARG NODE_VERSION=21.4.0-alpine3.18

# build assets & compile TypeScript

FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS native-builder

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
&& apt-get update \
&& apt-get install -yqq --no-install-recommends \
build-essential curl ca-certificates

ARG TARGETARCH

RUN curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-$TARGETARCH-static.tar.xz -o /ffmpeg.tar.xz \
&& tar xvf /ffmpeg.tar.xz -C / --strip-components 1 --wildcards 'ffmpeg-*-static/ffmpeg' 'ffmpeg-*-static/ffprobe'
FROM node:${NODE_VERSION} as build

RUN corepack enable

WORKDIR /sharkey

COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
COPY --link ["scripts", "./scripts"]
COPY --link ["packages/megalodon/package.json", "./packages/megalodon/"]
COPY --link ["packages/backend/package.json", "./packages/backend/"]
COPY --link ["packages/frontend/package.json", "./packages/frontend/"]
COPY --link ["packages/sw/package.json", "./packages/sw/"]
COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"]

RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm i --frozen-lockfile --aggregate-output
RUN apk add git linux-headers build-base

COPY --link . ./
ENV PYTHONUNBUFFERED=1
RUN apk add --update python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools

ARG NODE_ENV=production
COPY . ./

RUN git submodule update --init
RUN git submodule update --init --recursive
RUN pnpm config set fetch-retries 5
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm i
RUN pnpm build
RUN rm -rf .git/

# build native dependencies for target platform

FROM --platform=$TARGETPLATFORM node:${NODE_VERSION} AS target-builder

RUN apt-get update \
&& apt-get install -yqq --no-install-recommends \
build-essential

RUN corepack enable

WORKDIR /sharkey

COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
COPY --link ["scripts", "./scripts"]
COPY --link ["packages/megalodon/package.json", "./packages/megalodon/"]
COPY --link ["packages/backend/package.json", "./packages/backend/"]

RUN node scripts/trim-deps.mjs
RUN mv packages/frontend/assets sharkey-assets
RUN rm -r node_modules packages/frontend packages/sw
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm i --frozen-lockfile --aggregate-output

FROM --platform=$TARGETPLATFORM node:${NODE_VERSION}-slim AS runner
pnpm i --prod
RUN rm -rf .git

ARG UID="991"
ARG GID="991"
FROM node:${NODE_VERSION}

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
tini curl libjemalloc-dev libjemalloc2 \
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
&& corepack enable \
&& groupadd -g "${GID}" sharkey \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /sharkey sharkey \
&& find / -type d -path /proc -prune -o -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; \
&& find / -type d -path /proc -prune -o -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists

USER sharkey
WORKDIR /sharkey

COPY --chown=sharkey:sharkey --from=target-builder /sharkey/node_modules ./node_modules
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/megalodon/node_modules ./packages/megalodon/node_modules
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/backend/node_modules ./packages/backend/node_modules
COPY --chown=sharkey:sharkey --from=native-builder /ffmpeg /usr/local/bin/
COPY --chown=sharkey:sharkey --from=native-builder /ffprobe /usr/local/bin/
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/built ./built
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/megalodon/lib ./packages/megalodon/lib
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/backend/built ./packages/backend/built
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/fluent-emojis /sharkey/fluent-emojis
COPY --chown=sharkey:sharkey . ./
RUN apk add ffmpeg tini

COPY --from=build /sharkey/built ./built
COPY --from=build /sharkey/node_modules ./node_modules
COPY --from=build /sharkey/packages/backend/built ./packages/backend/built
COPY --from=build /sharkey/packages/backend/node_modules ./packages/backend/node_modules
COPY --from=build /sharkey/packages/megalodon/lib ./packages/megalodon/lib
COPY --from=build /sharkey/packages/megalodon/node_modules ./packages/megalodon/node_modules
COPY --from=build /sharkey/packages/misskey-js/built ./packages/misskey-js/built
COPY --from=build /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
COPY --from=build /sharkey/fluent-emojis ./fluent-emojis
COPY --from=build /sharkey/sharkey-assets ./packages/frontend/assets

COPY package.json ./package.json
COPY pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY packages/backend/package.json ./packages/backend/package.json
COPY packages/backend/check_connect.js ./packages/backend/check_connect.js
COPY packages/backend/ormconfig.js ./packages/backend/ormconfig.js
COPY packages/backend/migration ./packages/backend/migration
COPY packages/backend/assets ./packages/backend/assets
COPY packages/megalodon/package.json ./packages/megalodon/package.json
COPY packages/misskey-js/package.json ./packages/misskey-js/package.json

ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
ENV NODE_ENV=production
VOLUME "/sharkey/files"
HEALTHCHECK --interval=5s --retries=20 CMD ["/bin/bash", "/sharkey/healthcheck.sh"]
ENTRYPOINT ["/usr/bin/tini", "--"]
RUN corepack enable
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["pnpm", "run", "migrateandstart"]
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ approvalStatus: "Approval Status"
document: "Documentation"
numberOfPageCache: "Number of cached pages"
numberOfPageCacheDescription: "Increasing this number will improve convenience for but cause more load as more memory usage on the user's device."
numberOfReplies: "Number of replies in a thread"
numberOfRepliesDescription: "Increasing this number will display more replies. Setting this too high can cause replies to be cramped and unreadable."
logoutConfirm: "Really log out?"
lastActiveDate: "Last used at"
statusbar: "Status bar"
Expand Down
1 change: 1 addition & 0 deletions locales/es-ES.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,7 @@ _poll:
remainingHours: "Quedan {h} horas y {m} minutos para que finalice"
remainingMinutes: "Quedan {m} minutos y {s} segundos para que finalice"
remainingSeconds: "Quedan {s} segundos para que finalice"
multiple: "Opciones múltiples"
_visibility:
public: "Público"
publicDescription: "Visible para todos los usuarios"
Expand Down
2 changes: 2 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ export interface Locale {
"document": string;
"numberOfPageCache": string;
"numberOfPageCacheDescription": string;
"numberOfReplies": string;
"numberOfRepliesDescription": string;
"logoutConfirm": string;
"lastActiveDate": string;
"statusbar": string;
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ approvalStatus: "承認状況"
document: "ドキュメント"
numberOfPageCache: "ページキャッシュ数"
numberOfPageCacheDescription: "多くすると利便性が向上しますが、負荷とメモリ使用量が増えます。"
numberOfReplies: "スレッド内の返信数"
numberOfRepliesDescription: "この数値を大きくすると、より多くの返信が表示されます。この値を大きくしすぎると、返信が窮屈になり、読めなくなることがあります。"
logoutConfirm: "ログアウトしますか?"
lastActiveDate: "最終利用日時"
statusbar: "ステータスバー"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions packages/backend/assets/fonts/sharkey-icons/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@charset "UTF-8";

@font-face {
font-family: "custom-sharkey-icons";
src: url("./custom-sharkey-icons.woff") format("woff"),
url("./custom-sharkey-icons.ttf") format("truetype"),
url("./custom-sharkey-icons.svg#custom-sharkey-icons") format("svg");
font-weight: normal;
font-style: normal;
font-display: block;
}

.sk-icons {
font-family: "custom-sharkey-icons" !important;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.sk-icons.sk-shark:before {
content: "\61";
}

.sk-icons.sk-misskey:before {
content: "\62";
}
11 changes: 11 additions & 0 deletions packages/backend/migration/1701809447000-NSFW-Instance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class NSFWInstance1701809447000 {
name = 'NSFWInstance1701809447000'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "instance" ADD "isNSFW" boolean NOT NULL DEFAULT false`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "isNSFW"`);
}
}
13 changes: 12 additions & 1 deletion packages/backend/src/core/activitypub/models/ApImageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { DriveFilesRepository } from '@/models/_.js';
import type { DriveFilesRepository, InstancesRepository } from '@/models/_.js';
import type { MiRemoteUser } from '@/models/User.js';
import type { MiDriveFile } from '@/models/DriveFile.js';
import { MetaService } from '@/core/MetaService.js';
Expand All @@ -18,6 +18,7 @@ import { checkHttps } from '@/misc/check-https.js';
import { ApResolverService } from '../ApResolverService.js';
import { ApLoggerService } from '../ApLoggerService.js';
import type { IObject } from '../type.js';
import { UtilityService } from '@/core/UtilityService.js';

@Injectable()
export class ApImageService {
Expand All @@ -27,10 +28,14 @@ export class ApImageService {
@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,

@Inject(DI.instancesRepository)
private instancesRepository: InstancesRepository,

private metaService: MetaService,
private apResolverService: ApResolverService,
private driveService: DriveService,
private apLoggerService: ApLoggerService,
private utilityService: UtilityService,
) {
this.logger = this.apLoggerService.logger;
}
Expand Down Expand Up @@ -68,6 +73,12 @@ export class ApImageService {
// 2. or the image is not sensitive
const shouldBeCached = instance.cacheRemoteFiles && (instance.cacheRemoteSensitiveFiles || !image.sensitive);

const shouldBeSensitive = await this.instancesRepository.findOneBy({ host: this.utilityService.toPuny(actor.host), isNSFW: true });

if (shouldBeSensitive) {
image.sensitive = true;
}

const file = await this.driveService.uploadFromUrl({
url: image.url,
user: actor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class InstanceEntityService {
themeColor: instance.themeColor,
infoUpdatedAt: instance.infoUpdatedAt ? instance.infoUpdatedAt.toISOString() : null,
latestRequestReceivedAt: instance.latestRequestReceivedAt ? instance.latestRequestReceivedAt.toISOString() : null,
isNSFW: instance.isNSFW,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,9 @@ export class MiInstance {
nullable: true,
})
public infoUpdatedAt: Date | null;

@Column('boolean', {
default: false,
})
public isNSFW: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,10 @@ export const packedFederationInstanceSchema = {
optional: false, nullable: true,
format: 'date-time',
},
isNSFW: {
type: 'boolean',
optional: false,
nullable: false,
},
},
} as const;
Loading

0 comments on commit 00c85de

Please sign in to comment.