From 0faa4470fb41ea2f7ea2770b905bf7e17b7893cc Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Thu, 9 Sep 2021 19:28:02 +0900
Subject: [PATCH 1/6] =?UTF-8?q?GitHub=20Actions=E3=81=A7Docker=20Hub?=
 =?UTF-8?q?=E3=81=B8=E3=81=AEpush=E3=82=92=E8=A1=8C=E3=81=86=E3=82=88?=
 =?UTF-8?q?=E3=81=86=E3=81=AB=20(#7782)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Create docker.yml

* Update .github/workflows/docker.yml

Co-authored-by: tamaina <tamaina@hotmail.co.jp>

* add workflow_dispatch

* Multi-platform image

* Revert "Multi-platform image"

This reverts commit e5bac6632909a5020b0708227ebe248b443c2c2b.

Co-authored-by: tamaina <tamaina@hotmail.co.jp>
---
 .github/workflows/docker.yml | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 .github/workflows/docker.yml

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000000..1c6ad343e3
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,32 @@
+name: Publish Docker image
+
+on:
+  release:
+    types: [published]
+  workflow_dispatch:
+
+jobs:
+  push_to_registry:
+    name: Push Docker image to Docker Hub
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Check out the repo
+        uses: actions/checkout@v2
+      - name: Docker meta
+        id: meta
+        uses: docker/metadata-action@v3
+        with:
+          images: misskey/misskey
+      - name: Log in to Docker Hub
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PASSWORD }}
+      - name: Build and Push to Docker Hub
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}
+          labels: ${{ steps.meta.outputs.labels }}

From 935d6473edf259efa3b9c2c167a80cb960b07ad6 Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Thu, 9 Sep 2021 20:23:31 +0900
Subject: [PATCH 2/6] =?UTF-8?q?chore:=20API=E3=83=89=E3=82=AD=E3=83=A5?=
 =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E4=BF=AE=E6=AD=A3=20(#7771?=
 =?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* packedNotificationSchemaを更新

* read:gallery, write:gallery, read:gallery-likes, write:gallery-likesに翻訳を追加

* fix

* add header, choice, invitation
---
 locales/ja-JP.yml                       |  4 +++
 src/misc/api-permissions.ts             |  1 +
 src/models/repositories/notification.ts | 46 +++++++++++++++++++++----
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index e22f50668f..b9623ef0d0 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -1150,6 +1150,10 @@ _permissions:
   "write:user-groups": "ユーザーグループを操作する"
   "read:channels": "チャンネルを見る"
   "write:channels": "チャンネルを操作する"
+  "read:gallery": "ギャラリーを見る"
+  "write:gallery": "ギャラリーを操作する"
+  "read:gallery-likes": "ギャラリーのいいねを見る"
+  "write:gallery-likes": "ギャラリーのいいねを操作する"
 
 _auth:
   shareAccess: "「{name}」がアカウントにアクセスすることを許可しますか?"
diff --git a/src/misc/api-permissions.ts b/src/misc/api-permissions.ts
index eb20c3d289..160cdf9fd6 100644
--- a/src/misc/api-permissions.ts
+++ b/src/misc/api-permissions.ts
@@ -32,3 +32,4 @@ export const kinds = [
 	'read:gallery-likes',
 	'write:gallery-likes',
 ];
+// IF YOU ADD KINDS(PERMISSIONS), YOU MUST ADD TRANSLATIONS (under _permissions).
diff --git a/src/models/repositories/notification.ts b/src/models/repositories/notification.ts
index 55af96b6d7..ed9de7ef4c 100644
--- a/src/models/repositories/notification.ts
+++ b/src/models/repositories/notification.ts
@@ -7,6 +7,7 @@ import { Note } from '@/models/entities/note';
 import { NoteReaction } from '@/models/entities/note-reaction';
 import { User } from '@/models/entities/user';
 import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis';
+import { notificationTypes } from '@/types';
 
 export type PackedNotification = SchemaType<typeof packedNotificationSchema>;
 
@@ -124,20 +125,53 @@ export const packedNotificationSchema = {
 			optional: false as const, nullable: false as const,
 			format: 'date-time',
 		},
+		isRead: {
+			type: 'boolean' as const,
+			optional: false as const, nullable: false as const,
+		},
 		type: {
 			type: 'string' as const,
 			optional: false as const, nullable: false as const,
-			enum: ['follow', 'followRequestAccepted', 'receiveFollowRequest', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote'],
-		},
-		userId: {
-			type: 'string' as const,
-			optional: true as const, nullable: true as const,
-			format: 'id',
+			enum: [...notificationTypes],
 		},
 		user: {
 			type: 'object' as const,
 			ref: 'User',
 			optional: true as const, nullable: true as const,
 		},
+		userId: {
+			type: 'string' as const,
+			optional: true as const, nullable: true as const,
+			format: 'id',
+		},
+		note: {
+			type: 'object' as const,
+			ref: 'Note',
+			optional: true as const, nullable: true as const,
+		},
+		reaction: {
+			type: 'string' as const,
+			optional: true as const, nullable: true as const,
+		},
+		choice: {
+			type: 'number' as const,
+			optional: true as const, nullable: true as const,
+		},
+		invitation: {
+			type: 'object' as const,
+			optional: true as const, nullable: true as const,
+		},
+		body: {
+			type: 'string' as const,
+			optional: true as const, nullable: true as const,
+		},
+		header: {
+			type: 'string' as const,
+			optional: true as const, nullable: true as const,
+		},
+		icon: {
+			type: 'string' as const,
+			optional: true as const, nullable: true as const,
+		},
 	}
 };

From c63ba5470a1d04a86908d504c7044bd4987c20fc Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Sat, 11 Sep 2021 11:32:47 +0900
Subject: [PATCH 3/6] fix: use master branch when build docker image

---
 .github/workflows/docker.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 1c6ad343e3..fe6c3bfd20 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -13,6 +13,8 @@ jobs:
     steps:
       - name: Check out the repo
         uses: actions/checkout@v2
+        with:
+          ref: master
       - name: Docker meta
         id: meta
         uses: docker/metadata-action@v3

From f59f424795490e6ae2fe0be65ee3debb0776e939 Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Sat, 11 Sep 2021 11:37:35 +0900
Subject: [PATCH 4/6] Revert "fix: use master branch when build docker image"

This reverts commit c63ba5470a1d04a86908d504c7044bd4987c20fc.
---
 .github/workflows/docker.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index fe6c3bfd20..1c6ad343e3 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -13,8 +13,6 @@ jobs:
     steps:
       - name: Check out the repo
         uses: actions/checkout@v2
-        with:
-          ref: master
       - name: Docker meta
         id: meta
         uses: docker/metadata-action@v3

From 94ebf2ac5af89f01bdc3cc64764935e14bf379ce Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Sun, 12 Sep 2021 00:47:34 +0900
Subject: [PATCH 5/6] revert
 https://github.com/misskey-dev/misskey/pull/7772#discussion_r706627736

---
 test/utils.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/utils.ts b/test/utils.ts
index 253c410bf0..1a0c54463d 100644
--- a/test/utils.ts
+++ b/test/utils.ts
@@ -158,7 +158,7 @@ export async function initTestDb(justBorrow = false, initEntities?: any[]) {
 		await conn.close();
 	} catch (e) {}
 
-	return createConnection({
+	return await createConnection({
 		type: 'postgres',
 		host: config.db.host,
 		port: config.db.port,

From a7f5ad78b47faaafdd634c450161f6821201f03d Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Sun, 12 Sep 2021 00:46:38 +0900
Subject: [PATCH 6/6] =?UTF-8?q?user=20pack=E3=81=A8note=20pack=E3=81=AE?=
 =?UTF-8?q?=E5=9E=8B=E4=B8=8D=E6=95=B4=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/models/repositories/note.ts | 23 ++++++++++++++++++-----
 src/models/repositories/user.ts | 30 +++++++++---------------------
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts
index 77fedd791f..376a09d0c6 100644
--- a/src/models/repositories/note.ts
+++ b/src/models/repositories/note.ts
@@ -447,11 +447,24 @@ export const packedNoteSchema = {
 		channel: {
 			type: 'object' as const,
 			optional: true as const, nullable: true as const,
-			ref: 'Channel' as const,
+			items: {
+				type: 'object' as const,
+				optional: false as const, nullable: false as const,
+				properties: {
+					id: {
+						type: 'string' as const,
+						optional: false as const, nullable: false as const,
+					},
+					name: {
+						type: 'string' as const,
+						optional: false as const, nullable: true as const,
+					},
+				},
+			},
 		},
 		localOnly: {
 			type: 'boolean' as const,
-			optional: false as const, nullable: true as const,
+			optional: true as const, nullable: false as const,
 		},
 		emojis: {
 			type: 'array' as const,
@@ -466,7 +479,7 @@ export const packedNoteSchema = {
 					},
 					url: {
 						type: 'string' as const,
-						optional: false as const, nullable: false as const,
+						optional: false as const, nullable: true as const,
 					},
 				},
 			},
@@ -485,11 +498,11 @@ export const packedNoteSchema = {
 		},
 		uri: {
 			type: 'string' as const,
-			optional: false as const, nullable: true as const,
+			optional: true as const, nullable: false as const,
 		},
 		url: {
 			type: 'string' as const,
-			optional: false as const, nullable: true as const,
+			optional: true as const, nullable: false as const,
 		},
 
 		myReaction: {
diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts
index 4a6534b557..39c90cf5ed 100644
--- a/src/models/repositories/user.ts
+++ b/src/models/repositories/user.ts
@@ -375,12 +375,12 @@ export const packedUserSchema = {
 		},
 		isAdmin: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			default: false
 		},
 		isModerator: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			default: false
 		},
 		isBot: {
@@ -402,23 +402,11 @@ export const packedUserSchema = {
 						type: 'string' as const,
 						nullable: false as const, optional: false as const
 					},
-					host: {
-						type: 'string' as const,
-						nullable: true as const, optional: false as const
-					},
 					url: {
 						type: 'string' as const,
 						nullable: false as const, optional: false as const,
 						format: 'url'
 					},
-					aliases: {
-						type: 'array' as const,
-						nullable: false as const, optional: false as const,
-						items: {
-							type: 'string' as const,
-							nullable: false as const, optional: false as const
-						}
-					}
 				}
 			}
 		},
@@ -457,7 +445,7 @@ export const packedUserSchema = {
 		},
 		isSuspended: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			example: false
 		},
 		description: {
@@ -476,7 +464,7 @@ export const packedUserSchema = {
 		},
 		fields: {
 			type: 'array' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			items: {
 				type: 'object' as const,
 				nullable: false as const, optional: false as const,
@@ -525,26 +513,26 @@ export const packedUserSchema = {
 		},
 		pinnedPageId: {
 			type: 'string' as const,
-			nullable: true as const, optional: false as const
+			nullable: true as const, optional: true as const
 		},
 		pinnedPage: {
 			type: 'object' as const,
-			nullable: true as const, optional: false as const,
+			nullable: true as const, optional: true as const,
 			ref: 'Page' as const,
 		},
 		twoFactorEnabled: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			default: false
 		},
 		usePasswordLessLogin: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			default: false
 		},
 		securityKeys: {
 			type: 'boolean' as const,
-			nullable: false as const, optional: false as const,
+			nullable: false as const, optional: true as const,
 			default: false
 		},
 		avatarId: {