-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ForwardMessage } from '../client/QQClient'; | ||
import forwardHelper from '../helpers/forwardHelper'; | ||
import db from '../models/db'; | ||
|
||
export default async (messages: ForwardMessage[], fromPairId: number) => { | ||
for (const message of messages) { | ||
for (const elem of message.message) { | ||
if (elem.type !== 'json') continue; | ||
const parsed = forwardHelper.processJson(elem.data); | ||
if (parsed.type !== 'forward') continue; | ||
let entity = await db.forwardMultiple.findFirst({ where: { resId: parsed.resId } }); | ||
if (!entity) { | ||
entity = await db.forwardMultiple.create({ | ||
data: { | ||
resId: parsed.resId, | ||
fileName: parsed.fileName, | ||
fromPairId, | ||
}, | ||
}); | ||
} | ||
elem.data = JSON.stringify({ type: 'forward', uuid: entity.id }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters