Skip to content

Commit

Permalink
Merge pull request #11 from dev-hato/support_2023_10_x
Browse files Browse the repository at this point in the history
(WIP) add support v2023.10.2
  • Loading branch information
nakkaa authored Oct 26, 2023
2 parents 16fb29d + 7652d9d commit 48ea5f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## v0.1 - 2023/10/26

- Misskey 2023.10.2に対応しました。(#10)
- このバージョンより、aidのみのサポートとなります。
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

## 対象バージョン

- Misskey v13.12.2
- Meilisearch v1.1.1
- Misskey 2023.10.2 (aid)
- Postgresql 15.4
- meilisearch 1.4.2

## 使い方

Expand Down
14 changes: 11 additions & 3 deletions aminome.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import psycopg2.extras
import orjson
import requests
from datetime import datetime

# postgresql config
db = psycopg2.connect(
Expand All @@ -23,17 +24,24 @@
"Authorization": f"Bearer {api_key}"
}

# decode unixtimestamp (include milliseconds) from aid.
# ref. https://github.com/misskey-dev/misskey/blob/4b295088fd6b4bead05087537415b10419eee78f/packages/backend/src/misc/id/aid.ts#L34
def parse_aid(id):
TIME2000 = 946684800000
t = int(int(id[:8], 36) + TIME2000)
return t

lmt = 100000
ofs = 0

notes = []

while True:
with db.cursor() as cur:
cur.execute('SELECT "id", "createdAt", "userId", "userHost", "channelId", "cw", "text", "tags" FROM "note" \
cur.execute('SELECT "id", "userId", "userHost", "channelId", "cw", "text", "tags" FROM "note" \
WHERE ("note"."visibility" = \'public\' OR "note"."visibility" = \'home\') AND\
("note"."text" IS NOT NULL) AND\
( "note"."uri" IS NULL) \
("note"."uri" IS NULL) \
LIMIT ' + str(lmt) + ' OFFSET ' + str(ofs))
qnotes = cur.fetchall()
if not qnotes:
Expand All @@ -42,7 +50,7 @@
notes.append({
'id': note['id'],
'text': note['text'],
'createdAt': int(note['createdAt'].timestamp() * 1000),
'createdAt': parse_aid(note['id']),
'userId': note['userId'],
'userHost': note['userHost'],
'channelId': note['channelId'],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ idna==3.4
orjson==3.8.12
psycopg2-binary==2.9.6
requests==2.31.0
urllib3==2.0.6
urllib3==2.0.7

0 comments on commit 48ea5f1

Please sign in to comment.