v0.0.4
This commit is contained in:
19
cloudfunctions/conversationRead/index.js
Normal file
19
cloudfunctions/conversationRead/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const cloud = require('wx-server-sdk')
|
||||
|
||||
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
|
||||
const db = cloud.database()
|
||||
const _ = db.command
|
||||
|
||||
exports.main = async event => {
|
||||
const { OPENID } = cloud.getWXContext()
|
||||
if (!event.conversationId) throw new Error('conversationId is required')
|
||||
|
||||
await db.collection('conversations').doc(event.conversationId).update({
|
||||
data: {
|
||||
unreadOpenids: _.pull(OPENID),
|
||||
[`unreadCounts.${OPENID}`]: 0
|
||||
}
|
||||
})
|
||||
|
||||
return { unreadCount: 0 }
|
||||
}
|
||||
9
cloudfunctions/conversationRead/package.json
Normal file
9
cloudfunctions/conversationRead/package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "conversationRead",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user