Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-im
提交
9e8e5170
U
uni-im
项目概览
DCloud
/
uni-im
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-im
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9e8e5170
编写于
11月 18, 2024
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
3.4.40
上级
c41d9870
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
101 addition
and
37 deletion
+101
-37
changelog.md
changelog.md
+2
-0
package.json
package.json
+2
-1
uniCloud/cloudfunctions/uni-im-co/httpApi.js
uniCloud/cloudfunctions/uni-im-co/httpApi.js
+54
-0
uniCloud/cloudfunctions/uni-im-co/index.obj.js
uniCloud/cloudfunctions/uni-im-co/index.obj.js
+17
-11
uniCloud/cloudfunctions/uni-im-co/package.json
uniCloud/cloudfunctions/uni-im-co/package.json
+26
-25
未找到文件。
changelog.md
浏览文件 @
9e8e5170
## 3.4.40(2024-11-18)
uni-im-co 新增 httpApi 方法,方便第三方服务器调用其 url 化后的任意方法
## 3.4.39(2024-11-15)
## 3.4.39(2024-11-15)
-
新增 客户端错误日志收集功能
-
新增 客户端错误日志收集功能
-
修复 由3.4.37更新引起的解散群功能出错的问题
-
修复 由3.4.37更新引起的解散群功能出错的问题
...
...
package.json
浏览文件 @
9e8e5170
{
{
"id"
:
"uni-im"
,
"id"
:
"uni-im"
,
"displayName"
:
"uni-im"
,
"displayName"
:
"uni-im"
,
"version"
:
"3.4.
39
"
,
"version"
:
"3.4.
40
"
,
"description"
:
"uni-im是云端一体的、全平台的、免费的、开源即时通讯系统"
,
"description"
:
"uni-im是云端一体的、全平台的、免费的、开源即时通讯系统"
,
"keywords"
:
[
"keywords"
:
[
"im,即时通讯,客服,聊天"
"im,即时通讯,客服,聊天"
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
"uni_modules"
:
{
"uni_modules"
:
{
"dependencies"
:
[
"dependencies"
:
[
"uni-id-pages"
,
"uni-id-pages"
,
"uni-cloud-s2s"
,
"uni-search-bar"
,
"uni-search-bar"
,
"uni-segmented-control"
,
"uni-segmented-control"
,
"Sansnn-uQRCode"
,
"Sansnn-uQRCode"
,
...
...
uniCloud/cloudfunctions/uni-im-co/httpApi.js
0 → 100644
浏览文件 @
9e8e5170
const
{
verifyHttpInfo
}
=
require
(
'
uni-cloud-s2s
'
)
module
.
exports
=
async
function
httpApi
(
modules
){
// console.log('this.getClientInfo()',this.getClientInfo())
// 校验是否有权限调用
checkPermission
.
call
(
this
)
// 获取 HTTP 请求参数
const
[
param
,
options
]
=
getHttpParams
.
call
(
this
)
// 获取模拟操作的用户的信息
const
{
userInfo
,
clientInfo
}
=
options
this
.
current_uid
=
userInfo
.
_id
// 角色信息
this
.
current_user_role
=
userInfo
.
role
||
[]
// 设置客户端信息,例如设置客户端appid
if
(
clientInfo
){
this
.
clientInfo
=
Object
.
assign
(
this
.
getClientInfo
(),
clientInfo
)
}
const
funcName
=
Object
.
keys
(
param
)[
0
]
const
funcParam
=
Object
.
values
(
param
)[
0
]
// 执行要调用的方法
// console.log('funcName:',funcName)
// console.log('funcParam:',funcParam)
return
await
modules
[
funcName
].
call
(
this
,
funcParam
)
}
function
checkPermission
(){
if
(
this
.
getClientInfo
().
source
!=
'
http
'
){
throw
{
errCode
:
'
permission-denied
'
,
errMsg
:
'
仅限制 HTTP 调用
'
}
}
// 校验 HTTP 请求是否合法
verifyHttpInfo
(
this
.
getHttpInfo
())
}
function
getHttpParams
(){
// 获取 HTTP 请求相关信息
const
httpInfo
=
this
.
getHttpInfo
();
// 获取请求参数
let
params
=
httpInfo
.
body
// 尝试地将参数转换为 JSON 对象
try
{
params
=
JSON
.
parse
(
params
)
}
catch
(
_
)
{}
if
(
!
Array
.
isArray
(
params
)
||
(
params
.
length
!=
2
)
||
!
params
.
every
(
item
=>
Object
.
prototype
.
toString
.
call
(
item
)
===
'
[object Object]
'
))
{
throw
{
errCode
:
'
params-error
'
,
errMsg
:
'
参数错误:必须是长度为2的数组,且每一项都是对象,如:[{"方法名":"参数"},{"userInfo":{"_id":"执行操作的用户id"},"clientInfo":{"appid":"模拟的客户端appid"}}]
'
}
}
return
params
}
\ No newline at end of file
uniCloud/cloudfunctions/uni-im-co/index.obj.js
浏览文件 @
9e8e5170
const
httpApi
=
require
(
'
./httpApi.js
'
)
const
conversation
=
require
(
'
./conversation.js
'
)
const
conversation
=
require
(
'
./conversation.js
'
)
const
msg
=
require
(
'
./msg.js
'
)
const
msg
=
require
(
'
./msg.js
'
)
const
push
=
require
(
'
./push.js
'
)
const
push
=
require
(
'
./push.js
'
)
...
@@ -5,6 +6,15 @@ const friend = require('./friend.js')
...
@@ -5,6 +6,15 @@ const friend = require('./friend.js')
const
group
=
require
(
'
./group.js
'
)
const
group
=
require
(
'
./group.js
'
)
const
filtered_conversation
=
require
(
'
./filtered-conversation.js
'
)
const
filtered_conversation
=
require
(
'
./filtered-conversation.js
'
)
const
tools
=
require
(
'
./tools.js
'
)
const
tools
=
require
(
'
./tools.js
'
)
const
modules
=
Object
.
assign
(
conversation
,
msg
,
push
,
friend
,
group
,
filtered_conversation
,
tools
)
module
.
exports
=
{
module
.
exports
=
{
async
_before
()
{
async
_before
()
{
...
@@ -23,9 +33,9 @@ module.exports = {
...
@@ -23,9 +33,9 @@ module.exports = {
this
.
uniIdCommon
=
uniIdCommon
.
createInstance
({
this
.
uniIdCommon
=
uniIdCommon
.
createInstance
({
clientInfo
:
this
.
clientInfo
clientInfo
:
this
.
clientInfo
})
})
// 除非特定方法允许未登录用户调用,其它都需要验证用户的身份
// 除非特定方法允许未登录用户调用,其它都需要验证用户的身份
const
allowedMethodsWithouLogin
=
[]
const
allowedMethodsWithouLogin
=
[
"
httpApi
"
]
if
(
!
allowedMethodsWithouLogin
.
includes
(
this
.
getMethodName
()))
{
if
(
!
allowedMethodsWithouLogin
.
includes
(
this
.
getMethodName
()))
{
if
(
this
.
getClientInfo
().
source
==
'
function
'
)
{
if
(
this
.
getClientInfo
().
source
==
'
function
'
)
{
// 云函数互调时,免校验 token 直接使用传来的用户 id
// 云函数互调时,免校验 token 直接使用传来的用户 id
...
@@ -66,7 +76,7 @@ module.exports = {
...
@@ -66,7 +76,7 @@ module.exports = {
this
.
_promises
.
push
(
promise
)
this
.
_promises
.
push
(
promise
)
}
}
},
},
async
_after
(
error
,
result
)
{
async
_after
(
error
,
result
)
{
// 请求完成时间
// 请求完成时间
// console.error('请求完成时间', Date.now() - this.requestStartTime, 'ms')
// console.error('请求完成时间', Date.now() - this.requestStartTime, 'ms')
...
@@ -100,12 +110,8 @@ module.exports = {
...
@@ -100,12 +110,8 @@ module.exports = {
return
result
||
{
errCode
:
0
}
return
result
||
{
errCode
:
0
}
},
},
...
modules
,
...
conversation
,
httpApi
(){
...
msg
,
return
httpApi
.
call
(
this
,
modules
)
...
push
,
}
...
friend
,
...
group
,
...
filtered_conversation
,
...
tools
,
}
}
uniCloud/cloudfunctions/uni-im-co/package.json
浏览文件 @
9e8e5170
{
{
"name"
:
"uni-im-co"
,
"name"
:
"uni-im-co"
,
"dependencies"
:
{
"dependencies"
:
{
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"uni-cloud-s2s"
:
"file:../../../../uni-cloud-s2s/uniCloud/cloudfunctions/common/uni-cloud-s2s"
,
"uni-id-common"
:
"file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common"
,
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"uni-im-ext"
:
"file:../common/uni-im-ext"
,
"uni-id-common"
:
"file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common"
,
"uni-im-utils"
:
"file:../common/uni-im-utils"
"uni-im-ext"
:
"file:../common/uni-im-ext"
,
},
"uni-im-utils"
:
"file:../common/uni-im-utils"
"extensions"
:
{
},
"uni-cloud-jql"
:
{},
"extensions"
:
{
"uni-cloud-push"
:
{}
"uni-cloud-jql"
:
{},
},
"uni-cloud-push"
:
{}
"version"
:
"1.0.0"
,
},
"main"
:
"index.obj.js"
,
"version"
:
"1.0.0"
,
"scripts"
:
{
"main"
:
"index.obj.js"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"scripts"
:
{
},
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"keywords"
:
[],
},
"author"
:
""
,
"keywords"
:
[],
"license"
:
"ISC"
,
"author"
:
""
,
"description"
:
""
,
"license"
:
"ISC"
,
"cloudfunction-config"
:
{
"description"
:
""
,
"path"
:
"/uni-im-co"
,
"cloudfunction-config"
:
{
"runtime"
:
"Nodejs12"
"path"
:
"/uni-im-co"
,
}
"runtime"
:
"Nodejs12"
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录