├── .dockerignore ├── .env ├── .gitattributes ├── .github ├── .codecov.yml ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ ├── deployment.yml │ ├── documentation.md │ ├── feature-request.yml │ ├── other.yml │ └── rfc.md ├── sync-release.yml └── workflows │ ├── auto-assign-issue.yml │ ├── auto-invite-comment.yml │ ├── changelog.yml │ ├── cla-assistant.yml │ ├── cleanup-after-milestone-prs-merged.yml │ ├── codeql-analysis.yml │ ├── comment-check.yml │ ├── docker-build-and-release-services-images.yml │ ├── go-build-test.yml │ ├── help-comment-issue.yml │ ├── issue-translator.yml │ ├── merge-from-milestone.yml │ ├── publish-docker-image.yml │ ├── remove-unused-labels.yml │ ├── reopen-issue.yml │ ├── update-version-file-on-release.yml │ └── user-first-interaction.yml ├── .gitignore ├── .golangci.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING-zh_CN.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── README_zh_CN.md ├── assets ├── README.md ├── colors.md ├── demo │ ├── README.md │ ├── efficient-meetings.png │ ├── group-chat.png │ ├── hello-openim.png │ ├── multi-terminal-synchronization.png │ ├── multiple-message.png │ └── special-function.png ├── intive-slack.png ├── logo-gif │ ├── LICENSE │ └── openim-logo.gif ├── logo │ ├── LICENSE │ ├── openim-logo-blue.png │ ├── openim-logo-cyan.png │ ├── openim-logo-gradient.png │ ├── openim-logo-green.png │ ├── openim-logo-orange.png │ ├── openim-logo-purple.png │ ├── openim-logo-red.png │ ├── openim-logo-yellow.png │ └── openim-logo.png ├── openim-logo-gradient.pdf ├── openim-logo-gradient.svg ├── openim-logo-green.pdf └── openim-logo-green.svg ├── bootstrap.bat ├── bootstrap.sh ├── build ├── README.md ├── goreleaser.yaml └── images │ ├── Dockerfile │ ├── openim-api │ └── Dockerfile │ ├── openim-crontask │ └── Dockerfile │ ├── openim-msggateway │ └── Dockerfile │ ├── openim-msgtransfer │ └── Dockerfile │ ├── openim-push │ └── Dockerfile │ ├── openim-rpc-auth │ └── Dockerfile │ ├── openim-rpc-conversation │ └── Dockerfile │ ├── openim-rpc-friend │ └── Dockerfile │ ├── openim-rpc-group │ └── Dockerfile │ ├── openim-rpc-msg │ └── Dockerfile │ ├── openim-rpc-third │ └── Dockerfile │ ├── openim-rpc-user │ └── Dockerfile │ └── openim-tools │ └── component │ └── Dockerfile ├── cmd ├── main.go ├── openim-api │ └── main.go ├── openim-cmdutils │ └── main.go ├── openim-crontask │ └── main.go ├── openim-msggateway │ └── main.go ├── openim-msgtransfer │ └── main.go ├── openim-push │ └── main.go └── openim-rpc │ ├── openim-rpc-auth │ └── main.go │ ├── openim-rpc-conversation │ └── main.go │ ├── openim-rpc-friend │ └── main.go │ ├── openim-rpc-group │ └── main.go │ ├── openim-rpc-msg │ └── main.go │ ├── openim-rpc-third │ └── main.go │ └── openim-rpc-user │ └── main.go ├── config ├── README.md ├── README_zh_CN.md ├── alertmanager.yml ├── discovery.yml ├── email.tmpl ├── grafana-template │ └── Demo.json ├── instance-down-rules.yml ├── kafka.yml ├── local-cache.yml ├── log.yml ├── minio.yml ├── mongodb.yml ├── notification.yml ├── openim-api.yml ├── openim-crontask.yml ├── openim-msggateway.yml ├── openim-msgtransfer.yml ├── openim-push.yml ├── openim-rpc-auth.yml ├── openim-rpc-conversation.yml ├── openim-rpc-friend.yml ├── openim-rpc-group.yml ├── openim-rpc-msg.yml ├── openim-rpc-third.yml ├── openim-rpc-user.yml ├── prometheus.yml ├── redis.yml ├── share.yml └── webhooks.yml ├── deployments ├── Readme.md └── deploy │ ├── clusterRole.yml │ ├── ingress.yml │ ├── kafka-secret.yml │ ├── kafka-service.yml │ ├── kafka-statefulset.yml │ ├── minio-secret.yml │ ├── minio-service.yml │ ├── minio-statefulset.yml │ ├── mongo-secret.yml │ ├── mongo-service.yml │ ├── mongo-statefulset.yml │ ├── openim-api-deployment.yml │ ├── openim-api-service.yml │ ├── openim-config.yml │ ├── openim-crontask-deployment.yml │ ├── openim-msggateway-deployment.yml │ ├── openim-msggateway-service.yml │ ├── openim-msgtransfer-deployment.yml │ ├── openim-msgtransfer-service.yml │ ├── openim-push-deployment.yml │ ├── openim-push-service.yml │ ├── openim-rpc-auth-deployment.yml │ ├── openim-rpc-auth-service.yml │ ├── openim-rpc-conversation-deployment.yml │ ├── openim-rpc-conversation-service.yml │ ├── openim-rpc-friend-deployment.yml │ ├── openim-rpc-friend-service.yml │ ├── openim-rpc-group-deployment.yml │ ├── openim-rpc-group-service.yml │ ├── openim-rpc-msg-deployment.yml │ ├── openim-rpc-msg-service.yml │ ├── openim-rpc-third-deployment.yml │ ├── openim-rpc-third-service.yml │ ├── openim-rpc-user-deployment.yml │ ├── openim-rpc-user-service.yml │ ├── redis-secret.yml │ ├── redis-service.yml │ └── redis-statefulset.yml ├── docker-compose.yml ├── docs ├── .generated_docs ├── CODEOWNERS ├── README.md ├── contrib │ ├── README.md │ ├── api.md │ ├── bash-log.md │ ├── cicd-actions.md │ ├── code-conventions.md │ ├── commit.md │ ├── development.md │ ├── directory.md │ ├── environment.md │ ├── error-code.md │ ├── git-workflow.md │ ├── gitcherry-pick.md │ ├── github-workflow.md │ ├── go-code.md │ ├── go-code1.md │ ├── go-doc.md │ ├── images.md │ ├── init-config.md │ ├── install-docker.md │ ├── install-openim-linux-system.md │ ├── kafka.md │ ├── linux-development.md │ ├── local-actions.md │ ├── logging.md │ ├── mac-developer-deployment-guide.md │ ├── offline-deployment.md │ ├── prometheus-grafana.md │ ├── protoc-tools.md │ ├── release.md │ ├── test.md │ ├── util-go.md │ ├── util-makefile.md │ ├── util-scripts.md │ └── version.md ├── contributing │ ├── CONTRIBUTING-JP.md │ └── CONTRIBUTING-PL.md ├── images │ ├── architecture-layers.png │ ├── architecture.jpg │ ├── oepnim-design.png │ ├── open-im-logo.png │ ├── open-im-server.png │ └── wechat.jpg └── readme │ ├── README_cs.md │ ├── README_da.md │ ├── README_el.md │ ├── README_es.md │ ├── README_fa.md │ ├── README_fr.md │ ├── README_hu.md │ ├── README_ja.md │ ├── README_ko.md │ ├── README_tr.md │ ├── README_uk.md │ └── README_vi.md ├── go.mod ├── go.sum ├── install.sh ├── internal ├── api │ ├── auth.go │ ├── config_manager.go │ ├── conversation.go │ ├── custom_validator.go │ ├── friend.go │ ├── group.go │ ├── init.go │ ├── jssdk │ │ ├── jssdk.go │ │ ├── sort.go │ │ └── tools.go │ ├── msg.go │ ├── prometheus_discovery.go │ ├── router.go │ ├── third.go │ └── user.go ├── msggateway │ ├── callback.go │ ├── client.go │ ├── compressor.go │ ├── compressor_test.go │ ├── constant.go │ ├── context.go │ ├── encoder.go │ ├── http_error.go │ ├── hub_server.go │ ├── init.go │ ├── long_conn.go │ ├── message_handler.go │ ├── online.go │ ├── options.go │ ├── subscription.go │ ├── user_map.go │ └── ws_server.go ├── msgtransfer │ ├── callback.go │ ├── init.go │ ├── online_history_msg_handler.go │ └── online_msg_to_mongo_handler.go ├── push │ ├── callback.go │ ├── offlinepush │ │ ├── dummy │ │ │ └── push.go │ │ ├── fcm │ │ │ └── push.go │ │ ├── getui │ │ │ ├── body.go │ │ │ └── push.go │ │ ├── jpush │ │ │ ├── body │ │ │ │ ├── audience.go │ │ │ │ ├── message.go │ │ │ │ ├── notification.go │ │ │ │ ├── options.go │ │ │ │ ├── platform.go │ │ │ │ └── pushobj.go │ │ │ └── push.go │ │ ├── offlinepusher.go │ │ └── options │ │ │ └── options.go │ ├── offlinepush_handler.go │ ├── onlinepusher.go │ ├── push.go │ └── push_handler.go ├── rpc │ ├── auth │ │ └── auth.go │ ├── conversation │ │ ├── callback.go │ │ ├── conversation.go │ │ ├── db_map.go │ │ ├── notification.go │ │ └── sync.go │ ├── group │ │ ├── cache.go │ │ ├── callback.go │ │ ├── convert.go │ │ ├── db_map.go │ │ ├── fill.go │ │ ├── group.go │ │ ├── notification.go │ │ ├── statistics.go │ │ └── sync.go │ ├── incrversion │ │ ├── batch_option.go │ │ └── option.go │ ├── msg │ │ ├── as_read.go │ │ ├── callback.go │ │ ├── clear.go │ │ ├── delete.go │ │ ├── filter.go │ │ ├── msg_status.go │ │ ├── notification.go │ │ ├── revoke.go │ │ ├── send.go │ │ ├── seq.go │ │ ├── server.go │ │ ├── statistics.go │ │ ├── sync_msg.go │ │ ├── utils.go │ │ └── verify.go │ ├── relation │ │ ├── black.go │ │ ├── callback.go │ │ ├── friend.go │ │ ├── notification.go │ │ └── sync.go │ ├── third │ │ ├── log.go │ │ ├── s3.go │ │ ├── third.go │ │ └── tool.go │ └── user │ │ ├── callback.go │ │ ├── config.go │ │ ├── notification.go │ │ ├── online.go │ │ ├── statistics.go │ │ └── user.go └── tools │ └── cron │ ├── cron_task.go │ ├── cron_test.go │ ├── dist_look.go │ ├── msg.go │ ├── s3.go │ └── user_msg.go ├── magefile.go ├── magefile_unix.go ├── magefile_windows.go ├── pkg ├── apistruct │ ├── config_manager.go │ ├── doc.go │ ├── manage.go │ ├── msg.go │ └── public.go ├── authverify │ ├── doc.go │ └── token.go ├── callbackstruct │ ├── common.go │ ├── constant.go │ ├── conversation.go │ ├── doc.go │ ├── friend.go │ ├── group.go │ ├── message.go │ ├── msg_gateway.go │ ├── push.go │ ├── revoke.go │ └── user.go ├── common │ ├── cmd │ │ ├── api.go │ │ ├── auth.go │ │ ├── conversation.go │ │ ├── cron_task.go │ │ ├── doc.go │ │ ├── friend.go │ │ ├── group.go │ │ ├── msg.go │ │ ├── msg_gateway.go │ │ ├── msg_gateway_test.go │ │ ├── msg_transfer.go │ │ ├── msg_utils.go │ │ ├── push.go │ │ ├── root.go │ │ ├── third.go │ │ └── user.go │ ├── config │ │ ├── config.go │ │ ├── constant.go │ │ ├── doc.go │ │ ├── env.go │ │ ├── global.go │ │ ├── load_config.go │ │ ├── load_config_test.go │ │ └── parse.go │ ├── convert │ │ ├── black.go │ │ ├── conversation.go │ │ ├── doc.go │ │ ├── friend.go │ │ ├── group.go │ │ ├── msg.go │ │ ├── user.go │ │ └── user_test.go │ ├── discovery │ │ ├── direct │ │ │ ├── direct_resolver.go │ │ │ ├── directconn.go │ │ │ └── doc.go │ │ ├── discoveryregister.go │ │ ├── discoveryregister_test.go │ │ ├── doc.go │ │ ├── etcd │ │ │ ├── config_manager.go │ │ │ └── const.go │ │ └── kubernetes │ │ │ ├── doc.go │ │ │ └── kubernetes.go │ ├── ginprometheus │ │ ├── doc.go │ │ └── ginprometheus.go │ ├── prommetrics │ │ ├── api.go │ │ ├── grpc_auth.go │ │ ├── grpc_msg.go │ │ ├── grpc_msggateway.go │ │ ├── grpc_push.go │ │ ├── grpc_user.go │ │ ├── prommetrics.go │ │ ├── prommetrics_test.go │ │ ├── rpc.go │ │ └── transfer.go │ ├── servererrs │ │ ├── code.go │ │ ├── doc.go │ │ ├── predefine.go │ │ └── relation.go │ ├── startrpc │ │ ├── mw.go │ │ ├── start.go │ │ └── tools.go │ ├── storage │ │ ├── cache │ │ │ ├── batch_handler.go │ │ │ ├── black.go │ │ │ ├── cachekey │ │ │ │ ├── black.go │ │ │ │ ├── client_config.go │ │ │ │ ├── conversation.go │ │ │ │ ├── doc.go │ │ │ │ ├── friend.go │ │ │ │ ├── group.go │ │ │ │ ├── msg.go │ │ │ │ ├── online.go │ │ │ │ ├── s3.go │ │ │ │ ├── seq.go │ │ │ │ ├── third.go │ │ │ │ ├── token.go │ │ │ │ └── user.go │ │ │ ├── client_config.go │ │ │ ├── conversation.go │ │ │ ├── doc.go │ │ │ ├── friend.go │ │ │ ├── group.go │ │ │ ├── mcache │ │ │ │ ├── minio.go │ │ │ │ ├── msg_cache.go │ │ │ │ ├── online.go │ │ │ │ ├── seq_conversation.go │ │ │ │ ├── third.go │ │ │ │ ├── token.go │ │ │ │ └── tools.go │ │ │ ├── msg.go │ │ │ ├── online.go │ │ │ ├── redis │ │ │ │ ├── batch.go │ │ │ │ ├── batch_handler.go │ │ │ │ ├── batch_test.go │ │ │ │ ├── black.go │ │ │ │ ├── client_config.go │ │ │ │ ├── conversation.go │ │ │ │ ├── friend.go │ │ │ │ ├── group.go │ │ │ │ ├── lua_script.go │ │ │ │ ├── lua_script_test.go │ │ │ │ ├── minio.go │ │ │ │ ├── msg.go │ │ │ │ ├── online.go │ │ │ │ ├── online_test.go │ │ │ │ ├── redis_shard_manager.go │ │ │ │ ├── s3.go │ │ │ │ ├── seq_conversation.go │ │ │ │ ├── seq_conversation_test.go │ │ │ │ ├── seq_user.go │ │ │ │ ├── seq_user_test.go │ │ │ │ ├── third.go │ │ │ │ ├── token.go │ │ │ │ └── user.go │ │ │ ├── s3.go │ │ │ ├── seq_conversation.go │ │ │ ├── seq_user.go │ │ │ ├── third.go │ │ │ ├── token.go │ │ │ └── user.go │ │ ├── common │ │ │ └── types.go │ │ ├── controller │ │ │ ├── auth.go │ │ │ ├── black.go │ │ │ ├── client_config.go │ │ │ ├── conversation.go │ │ │ ├── doc.go │ │ │ ├── friend.go │ │ │ ├── group.go │ │ │ ├── msg.go │ │ │ ├── msg_transfer.go │ │ │ ├── push.go │ │ │ ├── s3.go │ │ │ ├── third.go │ │ │ └── user.go │ │ ├── database │ │ │ ├── black.go │ │ │ ├── cache.go │ │ │ ├── client_config.go │ │ │ ├── conversation.go │ │ │ ├── doc.go │ │ │ ├── friend.go │ │ │ ├── friend_request.go │ │ │ ├── group.go │ │ │ ├── group_member.go │ │ │ ├── group_request.go │ │ │ ├── log.go │ │ │ ├── mgo │ │ │ │ ├── black.go │ │ │ │ ├── cache.go │ │ │ │ ├── cache_test.go │ │ │ │ ├── client_config.go │ │ │ │ ├── conversation.go │ │ │ │ ├── doc.go │ │ │ │ ├── friend.go │ │ │ │ ├── friend_request.go │ │ │ │ ├── group.go │ │ │ │ ├── group_member.go │ │ │ │ ├── group_request.go │ │ │ │ ├── helpers.go │ │ │ │ ├── log.go │ │ │ │ ├── msg.go │ │ │ │ ├── msg_test.go │ │ │ │ ├── object.go │ │ │ │ ├── seq_conversation.go │ │ │ │ ├── seq_conversation_test.go │ │ │ │ ├── seq_user.go │ │ │ │ ├── user.go │ │ │ │ ├── version_log.go │ │ │ │ └── version_test.go │ │ │ ├── msg.go │ │ │ ├── name.go │ │ │ ├── object.go │ │ │ ├── seq.go │ │ │ ├── seq_user.go │ │ │ ├── user.go │ │ │ └── version_log.go │ │ ├── model │ │ │ ├── application.go │ │ │ ├── black.go │ │ │ ├── cache.go │ │ │ ├── client_config.go │ │ │ ├── conversation.go │ │ │ ├── doc.go │ │ │ ├── friend.go │ │ │ ├── friend_request.go │ │ │ ├── group.go │ │ │ ├── group_member.go │ │ │ ├── group_request.go │ │ │ ├── log.go │ │ │ ├── msg.go │ │ │ ├── object.go │ │ │ ├── seq.go │ │ │ ├── seq_user.go │ │ │ ├── subscribe.go │ │ │ ├── user.go │ │ │ └── version_log.go │ │ └── versionctx │ │ │ ├── rpc.go │ │ │ └── version.go │ └── webhook │ │ ├── condition.go │ │ ├── doc.go │ │ ├── http_client.go │ │ └── http_client_test.go ├── dbbuild │ ├── builder.go │ ├── microservices.go │ └── standalone.go ├── localcache │ ├── cache.go │ ├── cache_test.go │ ├── doc.go │ ├── init.go │ ├── link │ │ ├── doc.go │ │ ├── link.go │ │ └── link_test.go │ ├── lru │ │ ├── doc.go │ │ ├── lru.go │ │ ├── lru_expiration.go │ │ ├── lru_lazy.go │ │ ├── lru_lazy_test.go │ │ └── lru_slot.go │ ├── option.go │ └── tool.go ├── mqbuild │ └── builder.go ├── msgprocessor │ ├── conversation.go │ ├── doc.go │ └── options.go ├── notification │ ├── common_user │ │ └── common.go │ ├── grouphash │ │ └── grouphash.go │ └── msg.go ├── rpccache │ ├── common.go │ ├── conversation.go │ ├── doc.go │ ├── friend.go │ ├── group.go │ ├── online.go │ ├── subscriber.go │ └── user.go ├── rpcli │ ├── auth.go │ ├── conversation.go │ ├── group.go │ ├── msg.go │ ├── msggateway.go │ ├── push.go │ ├── relation.go │ ├── rtc.go │ ├── third.go │ ├── tool.go │ └── user.go ├── statistics │ ├── doc.go │ └── statistics.go ├── tools │ └── batcher │ │ ├── batcher.go │ │ └── batcher_test.go └── util │ ├── conversationutil │ ├── conversationutil.go │ └── doc.go │ ├── hashutil │ └── id.go │ └── useronline │ └── split.go ├── scripts └── template │ ├── LICENSE │ ├── LICENSE_TEMPLATES │ ├── boilerplate.txt │ ├── footer.md.tmpl │ ├── head.md.tmpl │ └── project_README.md ├── start-config.yml ├── test ├── e2e │ ├── README.md │ ├── api │ │ ├── token │ │ │ └── token.go │ │ └── user │ │ │ ├── curd.go │ │ │ └── user.go │ ├── conformance │ │ └── .keep │ ├── e2e.go │ ├── e2e_test.go │ ├── framework │ │ ├── config │ │ │ ├── config.go │ │ │ └── config_test.go │ │ ├── ginkgowrapper │ │ │ ├── .keep │ │ │ ├── ginkgowrapper.go │ │ │ └── ginkgowrapper_test.go │ │ └── helpers │ │ │ ├── .keep │ │ │ └── chat │ │ │ └── chat.go │ ├── page │ │ ├── chat_page.go │ │ └── login_page.go │ ├── performance │ │ └── .keep │ ├── rpc │ │ ├── auth │ │ │ └── .keep │ │ ├── conversation │ │ │ └── .keep │ │ ├── friend │ │ │ └── .keep │ │ ├── group │ │ │ └── .keep │ │ └── message │ │ │ └── .keep │ ├── scalability │ │ └── .keep │ ├── upgrade │ │ └── .keep │ └── web │ │ └── Readme.md ├── jwt │ └── main.go ├── readme ├── stress-test-v2 │ ├── README.md │ └── main.go ├── stress-test │ ├── README.md │ └── main.go ├── testdata │ ├── README.md │ ├── db │ │ ├── messages.json │ │ └── users.json │ ├── requests │ │ ├── login.json │ │ ├── register.json │ │ └── send-message.json │ └── responses │ │ ├── login.json │ │ ├── register.json │ │ └── sendMessage.json └── webhook │ └── msgmodify │ └── main.go ├── tools ├── README.md ├── changelog │ └── changelog.go ├── check-component │ └── main.go ├── check-free-memory │ └── main.go ├── imctl │ ├── .gitignore │ ├── README.md │ └── main.go ├── infra │ └── main.go ├── ncpu │ ├── README.md │ ├── main.go │ └── main_test.go ├── s3 │ ├── README.md │ ├── internal │ │ └── conversion.go │ └── main.go ├── seq │ ├── internal │ │ └── seq.go │ └── main.go ├── url2im │ ├── main.go │ └── pkg │ │ ├── api.go │ │ ├── buffer.go │ │ ├── config.go │ │ ├── http.go │ │ ├── manage.go │ │ ├── md5.go │ │ └── progress.go ├── versionchecker │ └── main.go └── yamlfmt │ ├── main.go │ └── main_test.go └── version ├── version └── version.go /.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignore files and directories starting with a dot 2 | 3 | # Ignore specific files 4 | .dockerignore 5 | .git 6 | 7 | # Ignore build artifacts 8 | logs/ 9 | _output/ 10 | # Ignore non-essential documentation 11 | README.md 12 | README-zh_CN.md 13 | CONTRIBUTING.md 14 | CHANGELOG/ 15 | # LICENSE 16 | 17 | # Ignore testing and linting configuration 18 | .golangci.yml 19 | 20 | 21 | # Ignore assets 22 | assets/ 23 | 24 | # Ignore components 25 | components/ 26 | 27 | # Ignore tools and scripts 28 | .github/ 29 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | MONGO_IMAGE=mongo:7.0 2 | REDIS_IMAGE=redis:7.0.0 3 | KAFKA_IMAGE=bitnami/kafka:3.5.1 4 | MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z 5 | ETCD_IMAGE=quay.io/coreos/etcd:v3.5.13 6 | PROMETHEUS_IMAGE=prom/prometheus:v2.45.6 7 | ALERTMANAGER_IMAGE=prom/alertmanager:v0.27.0 8 | GRAFANA_IMAGE=grafana/grafana:11.0.1 9 | NODE_EXPORTER_IMAGE=prom/node-exporter:v1.7.0 10 | 11 | OPENIM_WEB_FRONT_IMAGE=openim/openim-web-front:release-v3.8.3 12 | OPENIM_ADMIN_FRONT_IMAGE=openim/openim-admin-front:release-v1.8.4 13 | 14 | #FRONT_IMAGE: use aliyun images 15 | #OPENIM_WEB_FRONT_IMAGE=registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web-front:release-v3.8.3 16 | #OPENIM_ADMIN_FRONT_IMAGE=registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-admin-front:release-v1.8.4 17 | 18 | DATA_DIR=./ 19 | 20 | MONGO_BACKUP_DIR=${DATA_DIR}components/backup/mongo/ 21 | 22 | PROMETHEUS_PORT=19091 23 | ALERTMANAGER_PORT=19093 24 | GRAFANA_PORT=13000 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | -------------------------------------------------------------------------------- /.github/.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: false # disable the default status that measures entire project 5 | pkg: # declare a new status context "pkg" 6 | paths: 7 | - pkg/* # only include coverage in "pkg/" folder 8 | informational: true # Always pass check 9 | tools: # declare a new status context "tools" 10 | paths: 11 | - tools/* # only include coverage in "tools/" folder 12 | informational: true # Always pass check 13 | test: # declare a new status context "test" 14 | paths: 15 | - test/* # only include coverage in "test/" folder 16 | informational: true # Always pass check 17 | 18 | # internal: # declare a new status context "internal" 19 | # paths: 20 | # - internal/* # only include coverage in "internal/" folder 21 | # informational: true # Always pass check 22 | # cmd: # declare a new status context "cmd" 23 | # paths: 24 | # - cmd/* # only include coverage in "cmd/" folder 25 | # informational: true # Always pass check 26 | patch: off # disable the commit only checks 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | # - name: "Bug Report" 4 | # description: "Report a bug in the project" 5 | # file: "bug-report.yml" 6 | - name: 📢 Connect on slack 7 | url: https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg 8 | about: Support OpenIM-related requests or issues, get in touch with developers and help on slack 9 | - name: 🌐 OpenIM Blog 10 | url: https://www.openim.io/ 11 | about: Open the OpenIM community blog 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation Update 3 | about: Propose updates to documentation, including README files and other docs. 4 | title: "[DOC]: " # Prefix for the title to help identify documentation issues 5 | labels: documentation # Labels to be automatically added 6 | assignees: '' # Optionally, specify maintainers or teams to be auto-assigned 7 | 8 | --- 9 | 10 | ## Documentation Updates 11 | Describe the documentation that needs to be updated or corrected. Please specify the files and sections if possible. 12 | 13 | ## Motivation 14 | Explain why these updates are necessary. What is missing, misleading, or outdated? 15 | 16 | ## Suggested Changes 17 | Detail the changes that you propose. If you are suggesting large changes, include examples or mockups of what the updated documentation should look like. 18 | 19 | ## Additional Information 20 | Include any other information that might be relevant, such as links to discussions or related issues in the repository. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other.yml: -------------------------------------------------------------------------------- 1 | name: 🐧 Other 2 | description: Use this for any other issues. Please do NOT create blank issues 3 | title: "[Other]: " 4 | labels: ["other"] 5 | # assignees: [] 6 | 7 | 8 | body: 9 | - type: markdown 10 | attributes: 11 | value: "# Other issue" 12 | - type: textarea 13 | id: issuedescription 14 | attributes: 15 | label: What would you like to share? 16 | description: Provide a clear and concise explanation of your issue. 17 | validations: 18 | required: true 19 | - type: textarea 20 | id: extrainfo 21 | attributes: 22 | label: Additional information 23 | description: Is there anything else we should know about this issue? 24 | validations: 25 | required: false 26 | - type: markdown 27 | attributes: 28 | value: | 29 | You can also join our Discord community [here](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg) 30 | Feel free to check out other cool repositories of the openim Community [here](https://github.com/openimsdk) 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/rfc.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: RFC - Feature Proposal 3 | about: Submit a proposal for a significant feature to invite community discussion. 4 | title: "[RFC]: " # Prefix for the title to help identify RFC proposals 5 | labels: rfc, proposal # Labels to be automatically added 6 | assignees: '' # Optionally, specify maintainers or teams to be auto-assigned 7 | 8 | --- 9 | 10 | ## Proposal Overview 11 | Briefly describe the content and objectives of your proposal. 12 | 13 | ## Motivation 14 | Why is this new feature necessary? What is the background of this problem? 15 | 16 | ## Detailed Design 17 | Describe the technical details of the proposal, including implementation steps, code snippets, or architecture diagrams. 18 | 19 | ## Alternatives Considered 20 | Have other alternatives been considered? Why is this approach preferred over others? 21 | 22 | ## Impact 23 | How will this proposal affect existing practices and community users? 24 | 25 | ## Additional Information 26 | Include any other relevant information such as related discussions, prior related work, etc. 27 | -------------------------------------------------------------------------------- /.github/sync-release.yml: -------------------------------------------------------------------------------- 1 | openimsdk/openim-docker: 2 | - source: ./config 3 | dest: ./openim-server/release/config 4 | replace: true 5 | - source: ./docs 6 | dest: ./openim-server/release/docs 7 | replace: true 8 | - source: ./scripts 9 | dest: ./openim-server/release/scripts 10 | replace: true 11 | - source: ./scripts 12 | dest: ./scripts 13 | replace: false 14 | - source: ./Makefile 15 | dest: ./Makefile 16 | replace: false 17 | -------------------------------------------------------------------------------- /.github/workflows/issue-translator.yml: -------------------------------------------------------------------------------- 1 | name: 'issue-translator' 2 | on: 3 | issue_comment: 4 | types: [created] 5 | issues: 6 | types: [opened] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: usthe/issues-translate-action@v2.7 13 | with: 14 | BOT_GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} 15 | IS_MODIFY_TITLE: true 16 | # not require, default false, . Decide whether to modify the issue title 17 | # if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot. 18 | CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿 19 | # not require. Customize the translation robot prefix message. -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG/CHANGELOG.md -------------------------------------------------------------------------------- /assets/colors.md: -------------------------------------------------------------------------------- 1 | # Official Colors 2 | 3 | The openim logo has an official blue color. When reproducing the logo, please use the official color, when possible. 4 | 5 | ## Pantone 6 | 7 | When possible, the Pantone color is preferred for print material. The official Pantone color is *285C*. 8 | 9 | ## RGB 10 | 11 | When used digitally, the official RGB color code is *#326CE5*. 12 | -------------------------------------------------------------------------------- /assets/demo/README.md: -------------------------------------------------------------------------------- 1 | ## :star2: Why OpenIM 2 | 3 | **🔍 Function screenshot display** 4 | 5 |
6 | 7 | 8 | | multiple message | Efficient meetings | 9 | | :---------------------------------------: | :---------------------------------------------: | 10 | | ![multiple-message](./multiple-message.png) | ![efficient-meetings](./efficient-meetings.png) | 11 | | **One-to-one and group chats** | **Special features - Custom messages** | 12 | | ![group-chat](./group-chat.png) | ![special-function](./special-function.png) | 13 | 14 |
15 | -------------------------------------------------------------------------------- /assets/demo/efficient-meetings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/efficient-meetings.png -------------------------------------------------------------------------------- /assets/demo/group-chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/group-chat.png -------------------------------------------------------------------------------- /assets/demo/hello-openim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/hello-openim.png -------------------------------------------------------------------------------- /assets/demo/multi-terminal-synchronization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/multi-terminal-synchronization.png -------------------------------------------------------------------------------- /assets/demo/multiple-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/multiple-message.png -------------------------------------------------------------------------------- /assets/demo/special-function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/demo/special-function.png -------------------------------------------------------------------------------- /assets/intive-slack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/intive-slack.png -------------------------------------------------------------------------------- /assets/logo-gif/LICENSE: -------------------------------------------------------------------------------- 1 | # The OpenIM logo files are licensed under a choice of either Apache-2.0 or CC-BY-4.0 (Creative Commons Attribution 4.0 International). -------------------------------------------------------------------------------- /assets/logo-gif/openim-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo-gif/openim-logo.gif -------------------------------------------------------------------------------- /assets/logo/LICENSE: -------------------------------------------------------------------------------- 1 | # The OpenIM logo files are licensed under a choice of either Apache-2.0 or CC-BY-4.0 (Creative Commons Attribution 4.0 International). -------------------------------------------------------------------------------- /assets/logo/openim-logo-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-blue.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-cyan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-cyan.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-gradient.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-green.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-orange.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-purple.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-red.png -------------------------------------------------------------------------------- /assets/logo/openim-logo-yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo-yellow.png -------------------------------------------------------------------------------- /assets/logo/openim-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/logo/openim-logo.png -------------------------------------------------------------------------------- /assets/openim-logo-gradient.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/openim-logo-gradient.pdf -------------------------------------------------------------------------------- /assets/openim-logo-green.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/assets/openim-logo-green.pdf -------------------------------------------------------------------------------- /bootstrap.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | mage -version >nul 2>&1 5 | IF %ERRORLEVEL% EQU 0 ( 6 | echo Mage is already installed. 7 | GOTO DOWNLOAD 8 | ) 9 | 10 | go version >nul 2>&1 11 | IF NOT %ERRORLEVEL% EQU 0 ( 12 | echo Go is not installed. Please install Go and try again. 13 | exit /b 1 14 | ) 15 | 16 | echo Installing Mage... 17 | go install github.com/magefile/mage@latest 18 | 19 | mage -version >nul 2>&1 20 | IF NOT %ERRORLEVEL% EQU 0 ( 21 | echo Mage installation failed. 22 | echo Please ensure that %GOPATH%/bin is in your PATH. 23 | exit /b 1 24 | ) 25 | 26 | echo Mage installed successfully. 27 | 28 | :DOWNLOAD 29 | go mod download 30 | 31 | ENDLOCAL 32 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then 4 | TARGET_DIR="$HOME/.local/bin" 5 | else 6 | TARGET_DIR="/usr/local/bin" 7 | echo "Using /usr/local/bin as the installation directory. Might require sudo permissions." 8 | fi 9 | 10 | if ! command -v mage &> /dev/null; then 11 | echo "Installing Mage to $TARGET_DIR ..." 12 | GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest 13 | fi 14 | 15 | if ! command -v mage &> /dev/null; then 16 | echo "Mage installation failed." 17 | echo "Please ensure that $TARGET_DIR is in your \$PATH." 18 | exit 1 19 | fi 20 | 21 | echo "Mage installed successfully." 22 | 23 | go mod download 24 | -------------------------------------------------------------------------------- /build/images/Dockerfile: -------------------------------------------------------------------------------- 1 | # # Copyright © 2023 OpenIM. All rights reserved. 2 | # # 3 | # # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # # you may not use this file except in compliance with the License. 5 | # # You may obtain a copy of the License at 6 | # # 7 | # # http://www.apache.org/licenses/LICENSE-2.0 8 | # # 9 | # # Unless required by applicable law or agreed to in writing, software 10 | # # distributed under the License is distributed on an "AS IS" BASIS, 11 | # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # # See the License for the specific language governing permissions and 13 | # # limitations under the License. 14 | 15 | # FROM BASE_IMAGE 16 | 17 | # WORKDIR ${SERVER_WORKDIR} 18 | 19 | # # Set HTTP proxy 20 | # ARG BINARY_NAME 21 | 22 | # COPY BINARY_NAME ./bin/BINARY_NAME 23 | 24 | # ENTRYPOINT ["./bin/BINARY_NAME"] -------------------------------------------------------------------------------- /build/images/openim-api/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | 4 | # Define the base directory for the application as an environment variable 5 | ENV SERVER_DIR=/openim-server 6 | 7 | # Set the working directory inside the container based on the environment variable 8 | WORKDIR $SERVER_DIR 9 | 10 | # Set the Go proxy to improve dependency resolution speed 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | RUN go build -o _output/openim-api ./cmd/openim-api 19 | 20 | # Using Alpine Linux for the final image 21 | FROM alpine:latest 22 | 23 | # Install necessary packages, such as bash 24 | RUN apk add --no-cache bash 25 | 26 | # Set the environment and work directory 27 | ENV SERVER_DIR=/openim-server 28 | WORKDIR $SERVER_DIR 29 | 30 | 31 | # Copy the compiled binaries and mage from the builder image to the final image 32 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 33 | COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 34 | 35 | # Set the command to run when the container starts 36 | ENTRYPOINT ["sh", "-c", "_output/openim-api"] 37 | -------------------------------------------------------------------------------- /build/images/openim-crontask/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-crontask ./cmd/openim-crontask 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-crontask"] 40 | -------------------------------------------------------------------------------- /build/images/openim-msggateway/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-msggateway ./cmd/openim-msggateway 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-msggateway"] 40 | -------------------------------------------------------------------------------- /build/images/openim-msgtransfer/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-msgtransfer ./cmd/openim-msgtransfer 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-msgtransfer"] 40 | -------------------------------------------------------------------------------- /build/images/openim-push/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-push ./cmd/openim-push 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-push"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-auth/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-auth"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-conversation/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-conversation ./cmd/openim-rpc/openim-rpc-conversation 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-conversation"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-friend/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-friend ./cmd/openim-rpc/openim-rpc-friend 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-friend"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-group/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-group ./cmd/openim-rpc/openim-rpc-group 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-group"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-msg/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-msg ./cmd/openim-rpc/openim-rpc-msg 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-msg"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-third/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | 19 | 20 | RUN go build -o _output/openim-rpc-third ./cmd/openim-rpc/openim-rpc-third 21 | 22 | 23 | # Using Alpine Linux for the final image 24 | FROM alpine:latest 25 | 26 | # Install necessary packages, such as bash 27 | RUN apk add --no-cache bash 28 | 29 | # Set the environment and work directory 30 | ENV SERVER_DIR=/openim-server 31 | WORKDIR $SERVER_DIR 32 | 33 | 34 | # Copy the compiled binaries and mage from the builder image to the final image 35 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 36 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 37 | 38 | # Set the command to run when the container starts 39 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-third"] 40 | -------------------------------------------------------------------------------- /build/images/openim-rpc-user/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use Go 1.22 Alpine as the base image for building the application 2 | FROM golang:1.22-alpine AS builder 3 | # Define the base directory for the application as an environment variable 4 | ENV SERVER_DIR=/openim-server 5 | 6 | # Set the working directory inside the container based on the environment variable 7 | WORKDIR $SERVER_DIR 8 | 9 | # Set the Go proxy to improve dependency resolution speed 10 | 11 | #ENV GOPROXY=https://goproxy.io,direct 12 | 13 | # Copy all files from the current directory into the container 14 | COPY . . 15 | 16 | RUN go mod tidy 17 | 18 | RUN go build -o _output/openim-rpc-user ./cmd/openim-rpc/openim-rpc-user 19 | 20 | 21 | # Using Alpine Linux for the final image 22 | FROM alpine:latest 23 | 24 | # Install necessary packages, such as bash 25 | RUN apk add --no-cache bash 26 | 27 | # Set the environment and work directory 28 | ENV SERVER_DIR=/openim-server 29 | WORKDIR $SERVER_DIR 30 | 31 | 32 | # Copy the compiled binaries and mage from the builder image to the final image 33 | COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output 34 | # COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config 35 | 36 | # Set the command to run when the container starts 37 | ENTRYPOINT ["sh", "-c", "_output/openim-rpc-user"] 38 | -------------------------------------------------------------------------------- /cmd/openim-api/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | _ "net/http/pprof" 21 | ) 22 | 23 | func main() { 24 | if err := cmd.NewApiCmd().Exec(); err != nil { 25 | program.ExitWithError(err) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cmd/openim-crontask/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewCronTaskCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-msggateway/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewMsgGatewayCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-msgtransfer/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewMsgTransferCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-push/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewPushRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-auth/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewAuthRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-conversation/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewConversationRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-friend/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewFriendRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-group/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewGroupRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-msg/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewMsgRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-third/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewThirdRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cmd/openim-rpc/openim-rpc-user/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 19 | "github.com/openimsdk/tools/system/program" 20 | ) 21 | 22 | func main() { 23 | if err := cmd.NewUserRpcCmd().Exec(); err != nil { 24 | program.ExitWithError(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /config/alertmanager.yml: -------------------------------------------------------------------------------- 1 | global: 2 | resolve_timeout: 5m 3 | smtp_from: alert@openim.io 4 | smtp_smarthost: smtp.163.com:465 5 | smtp_auth_username: alert@openim.io 6 | smtp_auth_password: YOURAUTHPASSWORD 7 | smtp_require_tls: false 8 | smtp_hello: xxx 9 | 10 | templates: 11 | - /etc/alertmanager/email.tmpl 12 | 13 | route: 14 | group_by: [ 'alertname' ] 15 | group_wait: 5s 16 | group_interval: 5s 17 | repeat_interval: 5m 18 | receiver: email 19 | routes: 20 | - matchers: 21 | - alertname = "XXX" 22 | group_by: [ 'instance' ] 23 | group_wait: 5s 24 | group_interval: 5s 25 | repeat_interval: 5m 26 | receiver: email 27 | 28 | receivers: 29 | - name: email 30 | email_configs: 31 | - to: 'alert@example.com' 32 | html: '{{ template "email.to.html" . }}' 33 | headers: { Subject: "[OPENIM-SERVER]Alarm" } 34 | send_resolved: true 35 | -------------------------------------------------------------------------------- /config/discovery.yml: -------------------------------------------------------------------------------- 1 | enable: etcd 2 | etcd: 3 | rootDirectory: openim 4 | address: [ localhost:12379 ] 5 | username: '' 6 | password: '' 7 | 8 | kubernetes: 9 | namespace: default 10 | 11 | rpcService: 12 | user: user-rpc-service 13 | friend: friend-rpc-service 14 | msg: msg-rpc-service 15 | push: push-rpc-service 16 | messageGateway: messagegateway-rpc-service 17 | group: group-rpc-service 18 | auth: auth-rpc-service 19 | conversation: conversation-rpc-service 20 | third: third-rpc-service -------------------------------------------------------------------------------- /config/kafka.yml: -------------------------------------------------------------------------------- 1 | # Username for authentication 2 | username: '' 3 | # Password for authentication 4 | password: '' 5 | # Producer acknowledgment settings 6 | producerAck: 7 | # Compression type to use (e.g., none, gzip, snappy) 8 | compressType: none 9 | # List of Kafka broker addresses 10 | address: [ localhost:19094 ] 11 | # Kafka topic for Redis integration 12 | toRedisTopic: toRedis 13 | # Kafka topic for MongoDB integration 14 | toMongoTopic: toMongo 15 | # Kafka topic for push notifications 16 | toPushTopic: toPush 17 | # Kafka topic for offline push notifications 18 | toOfflinePushTopic: toOfflinePush 19 | # Consumer group ID for Redis topic 20 | toRedisGroupID: redis 21 | # Consumer group ID for MongoDB topic 22 | toMongoGroupID: mongo 23 | # Consumer group ID for push notifications topic 24 | toPushGroupID: push 25 | # Consumer group ID for offline push notifications topic 26 | toOfflinePushGroupID: offlinePush 27 | # TLS (Transport Layer Security) configuration 28 | tls: 29 | # Enable or disable TLS 30 | enableTLS: false 31 | # CA certificate file path 32 | caCrt: 33 | # Client certificate file path 34 | clientCrt: 35 | # Client key file path 36 | clientKey: 37 | # Client key password 38 | clientKeyPwd: 39 | # Whether to skip TLS verification (not recommended for production) 40 | insecureSkipVerify: false 41 | -------------------------------------------------------------------------------- /config/local-cache.yml: -------------------------------------------------------------------------------- 1 | user: 2 | topic: DELETE_CACHE_USER 3 | slotNum: 100 4 | slotSize: 2000 5 | successExpire: 300 6 | failedExpire: 5 7 | 8 | group: 9 | topic: DELETE_CACHE_GROUP 10 | slotNum: 100 11 | slotSize: 2000 12 | successExpire: 300 13 | failedExpire: 5 14 | 15 | friend: 16 | topic: DELETE_CACHE_FRIEND 17 | slotNum: 100 18 | slotSize: 2000 19 | successExpire: 300 20 | failedExpire: 5 21 | 22 | conversation: 23 | topic: DELETE_CACHE_CONVERSATION 24 | slotNum: 100 25 | slotSize: 2000 26 | successExpire: 300 27 | failedExpire: 5 28 | -------------------------------------------------------------------------------- /config/log.yml: -------------------------------------------------------------------------------- 1 | # Log storage path, default is acceptable, change to a full path if modification is needed 2 | storageLocation: ../../../../logs/ 3 | # Log rotation period (in hours), default is acceptable 4 | rotationTime: 24 5 | # Number of log files to retain, default is acceptable 6 | remainRotationCount: 2 7 | # Log level settings: 3 for production environment; 6 for more verbose logging in debugging environments 8 | remainLogLevel: 6 9 | # Whether to output to standard output, default is acceptable 10 | isStdout: false 11 | # Whether to log in JSON format, default is acceptable 12 | isJson: false 13 | # output simplify log when KeyAndValues's value len is bigger than 50 in rpc method log 14 | isSimplify: true -------------------------------------------------------------------------------- /config/minio.yml: -------------------------------------------------------------------------------- 1 | # Name of the bucket in MinIO 2 | bucket: openim 3 | # Access key ID for MinIO authentication 4 | accessKeyID: root 5 | # Secret access key for MinIO authentication 6 | secretAccessKey: openIM123 7 | # Session token for MinIO authentication (optional) 8 | sessionToken: 9 | # Internal address of the MinIO server 10 | internalAddress: localhost:10005 11 | # External address of the MinIO server, accessible from outside. Supports both HTTP and HTTPS using a domain name 12 | externalAddress: http://external_ip:10005 13 | # Flag to enable or disable public read access to the bucket 14 | publicRead: false 15 | 16 | 17 | -------------------------------------------------------------------------------- /config/mongodb.yml: -------------------------------------------------------------------------------- 1 | # URI for database connection, leave empty if using address and credential settings directly 2 | uri: 3 | # List of MongoDB server addresses 4 | address: [ localhost:37017 ] 5 | # Name of the database 6 | database: openim_v3 7 | # Username for database authentication 8 | username: openIM 9 | # Password for database authentication 10 | password: openIM123 11 | # Authentication source for database authentication, if use root user, set it to admin 12 | authSource: openim_v3 13 | # Maximum number of connections in the connection pool 14 | maxPoolSize: 100 15 | # Maximum number of retry attempts for a failed database connection 16 | maxRetry: 10 17 | -------------------------------------------------------------------------------- /config/openim-api.yml: -------------------------------------------------------------------------------- 1 | api: 2 | # Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended 3 | listenIP: 0.0.0.0 4 | # Listening ports; if multiple are configured, multiple instances will be launched, must be consistent with the number of prometheus.ports 5 | ports: [ 10002 ] 6 | # API compression level; 0: default compression, 1: best compression, 2: best speed, -1: no compression 7 | compressionLevel: 0 8 | 9 | 10 | prometheus: 11 | # Whether to enable prometheus 12 | enable: true 13 | # autoSetPorts indicates whether to automatically set the ports 14 | autoSetPorts: true 15 | # Prometheus listening ports, must match the number of api.ports 16 | # It will only take effect when autoSetPorts is set to false. 17 | ports: 18 | # This address can be accessed via a browser 19 | grafanaURL: 20 | -------------------------------------------------------------------------------- /config/openim-crontask.yml: -------------------------------------------------------------------------------- 1 | cronExecuteTime: 0 2 * * * 2 | retainChatRecords: 365 3 | fileExpireTime: 180 4 | deleteObjectType: ["msg-picture","msg-file", "msg-voice","msg-video","msg-video-snapshot","sdklog"] -------------------------------------------------------------------------------- /config/openim-msggateway.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # autoSetPorts indicates whether to automatically set the ports 5 | # if you use in kubernetes, set it to false 6 | autoSetPorts: true 7 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 8 | # It will only take effect when autoSetPorts is set to false. 9 | ports: 10 | 11 | prometheus: 12 | # Enable or disable Prometheus monitoring 13 | enable: true 14 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 15 | # It will only take effect when autoSetPorts is set to false. 16 | ports: 17 | # IP address that the RPC/WebSocket service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 18 | listenIP: 0.0.0.0 19 | 20 | longConnSvr: 21 | # WebSocket listening ports, must match the number of rpc.ports 22 | ports: [ 10001 ] 23 | # Maximum number of WebSocket connections 24 | websocketMaxConnNum: 100000 25 | # Maximum length of the entire WebSocket message packet 26 | websocketMaxMsgLen: 4096 27 | # WebSocket connection handshake timeout in seconds 28 | websocketTimeout: 10 29 | -------------------------------------------------------------------------------- /config/openim-msgtransfer.yml: -------------------------------------------------------------------------------- 1 | prometheus: 2 | # Enable or disable Prometheus monitoring 3 | enable: true 4 | # autoSetPorts indicates whether to automatically set the ports 5 | autoSetPorts: true 6 | # List of ports that Prometheus listens on; each port corresponds to an instance of monitoring. Ensure these are managed accordingly 7 | # It will only take effect when autoSetPorts is set to false. 8 | ports: 9 | -------------------------------------------------------------------------------- /config/openim-rpc-auth.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Enable or disable Prometheus monitoring 15 | enable: true 16 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | 20 | tokenPolicy: 21 | # Token validity period, in days 22 | expire: 90 23 | -------------------------------------------------------------------------------- /config/openim-rpc-conversation.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Enable or disable Prometheus monitoring 15 | enable: true 16 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | -------------------------------------------------------------------------------- /config/openim-rpc-friend.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Enable or disable Prometheus monitoring 15 | enable: true 16 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | -------------------------------------------------------------------------------- /config/openim-rpc-group.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Enable or disable Prometheus monitoring 15 | enable: true 16 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | 20 | 21 | enableHistoryForNewMembers: true 22 | -------------------------------------------------------------------------------- /config/openim-rpc-msg.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP 3 | registerIP: 4 | # IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Enable or disable Prometheus monitoring 15 | enable: true 16 | # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | 20 | 21 | # Does sending messages require friend verification 22 | friendVerify: false 23 | -------------------------------------------------------------------------------- /config/openim-rpc-user.yml: -------------------------------------------------------------------------------- 1 | rpc: 2 | # API or other RPCs can access this RPC through this IP; if left blank, the internal network IP is obtained by default 3 | registerIP: 4 | # Listening IP; 0.0.0.0 means both internal and external IPs are listened to, if blank, the internal network IP is automatically obtained by default 5 | listenIP: 0.0.0.0 6 | # autoSetPorts indicates whether to automatically set the ports 7 | # if you use in kubernetes, set it to false 8 | autoSetPorts: true 9 | # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports 10 | # It will only take effect when autoSetPorts is set to false. 11 | ports: 12 | 13 | prometheus: 14 | # Whether to enable prometheus 15 | enable: true 16 | # Prometheus listening ports, must be consistent with the number of rpc.ports 17 | # It will only take effect when autoSetPorts is set to false. 18 | ports: 19 | -------------------------------------------------------------------------------- /config/redis.yml: -------------------------------------------------------------------------------- 1 | address: [ localhost:16379 ] 2 | username: 3 | password: openIM123 4 | clusterMode: false 5 | db: 0 6 | maxRetry: 10 7 | poolSize: 100 8 | -------------------------------------------------------------------------------- /config/share.yml: -------------------------------------------------------------------------------- 1 | secret: openIM123 2 | 3 | imAdminUserID: [imAdmin] 4 | 5 | # 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time 6 | multiLogin: 7 | policy: 1 8 | # max num of tokens in one end 9 | maxNumOneEnd: 30 10 | 11 | rpcMaxBodySize: 12 | requestMaxBodySize: 8388608 13 | responseMaxBodySize: 8388608 14 | -------------------------------------------------------------------------------- /deployments/deploy/clusterRole.yml: -------------------------------------------------------------------------------- 1 | # ClusterRole.yaml 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: service-reader 6 | rules: 7 | - apiGroups: [""] 8 | resources: ["services", "endpoints"] 9 | verbs: ["get", "list", "watch"] 10 | 11 | --- 12 | # ClusterRoleBinding.yaml 13 | apiVersion: rbac.authorization.k8s.io/v1 14 | kind: ClusterRoleBinding 15 | metadata: 16 | name: default-service-reader-binding 17 | subjects: 18 | - kind: ServiceAccount 19 | name: default 20 | namespace: default 21 | roleRef: 22 | kind: ClusterRole 23 | name: service-reader 24 | apiGroup: rbac.authorization.k8s.io 25 | -------------------------------------------------------------------------------- /deployments/deploy/ingress.yml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: openim-ingress 5 | annotations: 6 | nginx.ingress.kubernetes.io/rewrite-target: / 7 | spec: 8 | ingressClassName: openim-nginx 9 | rules: 10 | - http: 11 | paths: 12 | - path: /openim-api 13 | pathType: Prefix 14 | backend: 15 | service: 16 | name: openim-api-service 17 | port: 18 | number: 10002 19 | - path: /openim-msggateway 20 | pathType: Prefix 21 | backend: 22 | service: 23 | name: openim-msggateway-service 24 | port: 25 | number: 10001 26 | -------------------------------------------------------------------------------- /deployments/deploy/kafka-secret.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: openim-kafka-secret 5 | type: Opaque 6 | data: 7 | kafka-password: "" 8 | -------------------------------------------------------------------------------- /deployments/deploy/kafka-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: kafka-service 5 | labels: 6 | app: kafka 7 | spec: 8 | ports: 9 | - name: plaintext 10 | port: 9092 11 | targetPort: 9092 12 | - name: controller 13 | port: 9093 14 | targetPort: 9093 15 | - name: external 16 | port: 19094 17 | targetPort: 9094 18 | selector: 19 | app: kafka 20 | type: ClusterIP 21 | -------------------------------------------------------------------------------- /deployments/deploy/minio-secret.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: openim-minio-secret 5 | type: Opaque 6 | data: 7 | minio-root-user: cm9vdA== # Base64 encoded "root" 8 | minio-root-password: b3BlbklNMTIz # Base64 encoded "openIM123" 9 | -------------------------------------------------------------------------------- /deployments/deploy/minio-service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: minio-service 6 | spec: 7 | selector: 8 | app: minio 9 | ports: 10 | - name: minio 11 | protocol: TCP 12 | port: 10005 # External port for accessing MinIO service 13 | targetPort: 9000 # Container port for MinIO service 14 | - name: minio-console 15 | protocol: TCP 16 | port: 19090 # External port for accessing MinIO console 17 | targetPort: 9090 # Container port for MinIO console 18 | type: NodePort 19 | -------------------------------------------------------------------------------- /deployments/deploy/mongo-secret.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: openim-mongo-secret 5 | type: Opaque 6 | data: 7 | mongo_openim_username: b3BlbklN # base64 for "openIM", this user credentials need in authSource database. 8 | mongo_openim_password: b3BlbklNMTIz # base64 for "openIM123" 9 | -------------------------------------------------------------------------------- /deployments/deploy/mongo-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mongo-service 5 | spec: 6 | selector: 7 | app: mongo 8 | ports: 9 | - name: mongodb-port 10 | protocol: TCP 11 | port: 37017 12 | targetPort: 27017 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /deployments/deploy/openim-api-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: openim-api-service 5 | spec: 6 | selector: 7 | app: openim-api 8 | ports: 9 | - name: http-10002 10 | protocol: TCP 11 | port: 10002 12 | targetPort: 10002 13 | - name: prometheus-12002 14 | protocol: TCP 15 | port: 12002 16 | targetPort: 12002 17 | type: NodePort 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-crontask-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: openim-crontask 5 | spec: 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: crontask 10 | template: 11 | metadata: 12 | labels: 13 | app: crontask 14 | spec: 15 | containers: 16 | - name: crontask-container 17 | image: openim/openim-crontask:v3.8.3 18 | env: 19 | - name: CONFIG_PATH 20 | value: "/config" 21 | volumeMounts: 22 | - name: openim-config 23 | mountPath: "/config" 24 | readOnly: true 25 | volumes: 26 | - name: openim-config 27 | configMap: 28 | name: openim-config 29 | -------------------------------------------------------------------------------- /deployments/deploy/openim-msggateway-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: messagegateway-rpc-server 5 | spec: 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: messagegateway-rpc-server 10 | template: 11 | metadata: 12 | labels: 13 | app: messagegateway-rpc-server 14 | spec: 15 | containers: 16 | - name: openim-msggateway-container 17 | image: openim/openim-msggateway:v3.8.3 18 | env: 19 | - name: CONFIG_PATH 20 | value: "/config" 21 | - name: IMENV_REDIS_PASSWORD 22 | valueFrom: 23 | secretKeyRef: 24 | name: openim-redis-secret 25 | key: redis-password 26 | volumeMounts: 27 | - name: openim-config 28 | mountPath: "/config" 29 | readOnly: true 30 | ports: 31 | - containerPort: 10140 32 | - containerPort: 12001 33 | volumes: 34 | - name: openim-config 35 | configMap: 36 | name: openim-config 37 | -------------------------------------------------------------------------------- /deployments/deploy/openim-msggateway-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: messagegateway-rpc-service 5 | spec: 6 | selector: 7 | app: messagegateway-rpc-server 8 | ports: 9 | - name: longConnServer-10001 10 | protocol: TCP 11 | port: 10001 12 | targetPort: 10001 13 | - name: grpc-10140 14 | protocol: TCP 15 | port: 10140 16 | targetPort: 10140 17 | - name: prometheus-12001 18 | protocol: TCP 19 | port: 12001 20 | targetPort: 12001 21 | type: NodePort 22 | -------------------------------------------------------------------------------- /deployments/deploy/openim-msgtransfer-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: openim-msgtransfer-service 5 | spec: 6 | selector: 7 | app: openim-msgtransfer-server 8 | ports: 9 | - name: prometheus-12020 10 | protocol: TCP 11 | port: 12020 12 | targetPort: 12020 13 | type: ClusterIP 14 | -------------------------------------------------------------------------------- /deployments/deploy/openim-push-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: push-rpc-server 5 | spec: 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: push-rpc-server 10 | template: 11 | metadata: 12 | labels: 13 | app: push-rpc-server 14 | spec: 15 | containers: 16 | - name: push-rpc-server-container 17 | image: openim/openim-push:v3.8.3 18 | env: 19 | - name: CONFIG_PATH 20 | value: "/config" 21 | - name: IMENV_REDIS_PASSWORD 22 | valueFrom: 23 | secretKeyRef: 24 | name: openim-redis-secret 25 | key: redis-password 26 | - name: IMENV_KAFKA_PASSWORD 27 | valueFrom: 28 | secretKeyRef: 29 | name: openim-kafka-secret 30 | key: kafka-password 31 | volumeMounts: 32 | - name: openim-config 33 | mountPath: "/config" 34 | readOnly: true 35 | ports: 36 | - containerPort: 10170 37 | - containerPort: 12170 38 | volumes: 39 | - name: openim-config 40 | configMap: 41 | name: openim-config 42 | -------------------------------------------------------------------------------- /deployments/deploy/openim-push-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: push-rpc-service 5 | spec: 6 | selector: 7 | app: push-rpc-server 8 | ports: 9 | - name: http-10170 10 | protocol: TCP 11 | port: 10170 12 | targetPort: 10170 13 | - name: prometheus-12170 14 | protocol: TCP 15 | port: 12170 16 | targetPort: 12170 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-auth-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: auth-rpc-server 5 | spec: 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: auth-rpc-server 10 | template: 11 | metadata: 12 | labels: 13 | app: auth-rpc-server 14 | spec: 15 | containers: 16 | - name: auth-rpc-server-container 17 | image: openim/openim-rpc-auth:v3.8.3 18 | imagePullPolicy: Never 19 | env: 20 | - name: CONFIG_PATH 21 | value: "/config" 22 | - name: IMENV_REDIS_PASSWORD 23 | valueFrom: 24 | secretKeyRef: 25 | name: openim-redis-secret 26 | key: redis-password 27 | volumeMounts: 28 | - name: openim-config 29 | mountPath: "/config" 30 | readOnly: true 31 | ports: 32 | - containerPort: 10200 33 | - containerPort: 12200 34 | volumes: 35 | - name: openim-config 36 | configMap: 37 | name: openim-config 38 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-auth-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: auth-rpc-service 5 | spec: 6 | selector: 7 | app: auth-rpc-server 8 | ports: 9 | - name: http-10200 10 | protocol: TCP 11 | port: 10200 12 | targetPort: 10200 13 | - name: prometheus-12200 14 | protocol: TCP 15 | port: 12200 16 | targetPort: 12200 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-conversation-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: conversation-rpc-service 5 | spec: 6 | selector: 7 | app: conversation-rpc-server 8 | ports: 9 | - name: http-10220 10 | protocol: TCP 11 | port: 10220 12 | targetPort: 10220 13 | - name: prometheus-12220 14 | protocol: TCP 15 | port: 12220 16 | targetPort: 12220 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-friend-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: friend-rpc-service 5 | spec: 6 | selector: 7 | app: friend-rpc-server 8 | ports: 9 | - name: http-10240 10 | protocol: TCP 11 | port: 10240 12 | targetPort: 10240 13 | - name: prometheus-12240 14 | protocol: TCP 15 | port: 12240 16 | targetPort: 12240 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-group-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: group-rpc-service 5 | spec: 6 | selector: 7 | app: group-rpc-server 8 | ports: 9 | - name: http-10260 10 | protocol: TCP 11 | port: 10260 12 | targetPort: 10260 13 | - name: prometheus-12260 14 | protocol: TCP 15 | port: 12260 16 | targetPort: 12260 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-msg-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: msg-rpc-service 5 | spec: 6 | selector: 7 | app: msg-rpc-server 8 | ports: 9 | - name: http-10280 10 | protocol: TCP 11 | port: 10280 12 | targetPort: 10280 13 | - name: prometheus-12280 14 | protocol: TCP 15 | port: 12280 16 | targetPort: 12280 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-third-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: third-rpc-service 5 | spec: 6 | selector: 7 | app: third-rpc-server 8 | ports: 9 | - name: http-10300 10 | protocol: TCP 11 | port: 10300 12 | targetPort: 10300 13 | - name: prometheus-12300 14 | protocol: TCP 15 | port: 12300 16 | targetPort: 12300 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/openim-rpc-user-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: user-rpc-service 5 | spec: 6 | selector: 7 | app: user-rpc-server 8 | ports: 9 | - name: http-10320 10 | protocol: TCP 11 | port: 10320 12 | targetPort: 10320 13 | - name: prometheus-12320 14 | protocol: TCP 15 | port: 12320 16 | targetPort: 12320 17 | type: ClusterIP 18 | -------------------------------------------------------------------------------- /deployments/deploy/redis-secret.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: openim-redis-secret 5 | type: Opaque 6 | data: 7 | redis-password: b3BlbklNMTIz # "openIM123" in base64 8 | -------------------------------------------------------------------------------- /deployments/deploy/redis-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: redis-service 5 | labels: 6 | app: redis 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | app: redis 11 | ports: 12 | - name: redis-port 13 | protocol: TCP 14 | port: 16379 15 | targetPort: 6379 16 | -------------------------------------------------------------------------------- /docs/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS file 2 | # This file is used to specify the individuals who are required to review changes in this repository. 3 | 4 | * @Bloomingg @FGadvancer @skiffer-git @withchao -------------------------------------------------------------------------------- /docs/contrib/api.md: -------------------------------------------------------------------------------- 1 | ## Interface Standards 2 | 3 | Our project, OpenIM, adheres to the [OpenAPI 3.0](https://spec.openapis.org/oas/latest.html) interface standards. 4 | 5 | > Chinese translation: [OpenAPI Specification Chinese Translation](https://fishead.gitbook.io/openapi-specification-zhcn-translation/3.0.0.zhcn) -------------------------------------------------------------------------------- /docs/contrib/commit.md: -------------------------------------------------------------------------------- 1 | ## Commit Standards 2 | 3 | Our project, OpenIM, follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) standards. 4 | 5 | > Chinese translation: [Conventional Commits: A Specification Making Commit Logs More Human and Machine-friendly](https://tool.lu/en_US/article/2ac/preview) 6 | 7 | In addition to adhering to these standards, we encourage all contributors to the OpenIM project to ensure that their commit messages are clear and descriptive. This helps in maintaining a clean and meaningful project history. Each commit message should succinctly describe the changes made and, where necessary, the reasoning behind those changes. 8 | 9 | To facilitate a streamlined process, we also recommend using appropriate commit type based on Conventional Commits guidelines such as `fix:` for bug fixes, `feat:` for new features, and so forth. Understanding and using these conventions helps in generating automatic release notes, making versioning easier, and improving overall readability of commit history. -------------------------------------------------------------------------------- /docs/contrib/directory.md: -------------------------------------------------------------------------------- 1 | ## Catalog Service Interface Specification 2 | 3 | + [https://github.com/kubecub/go-project-layout](https://github.com/kubecub/go-project-layout) -------------------------------------------------------------------------------- /docs/contrib/install-docker.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | # Install Docker 9 | 10 | 11 | The installation command is as follows: 12 | 13 | ```bash 14 | $ curl -fsSL https://get.docker.com | bash -s docker --mirror aliyun 15 | `` 16 | 17 | ## 2.2 Start Docker 18 | 19 | ```bash 20 | $ systemctl start docker 21 | ``` 22 | 23 | ## 2.3 Test Docker 24 | 25 | ```bash 26 | $ docker run hello-world 27 | ``` 28 | 29 | ## 2.4 Configure Docker Acceleration 30 | 31 | ```bash 32 | $ mkdir -p /etc/docker 33 | $ tee /etc/docker/daemon.json <<-'EOF' 34 | { 35 | "registry-mirrors": ["https://registry.docker-cn.com"] 36 | } 37 | EOF 38 | $ systemctl daemon-reload 39 | $ systemctl restart docker 40 | ``` 41 | 42 | ## 2.5 Install Docker Compose 43 | 44 | ```bash 45 | $ sudo curl -L "https://github.com/docker/compose/releases/download/latest/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 46 | $ sudo chmod +x /usr/local/bin/docker-compose 47 | ``` 48 | 49 | ## 2.6 Test Docker Compose 50 | 51 | ```bash 52 | $ docker-compose --version 53 | ``` 54 | -------------------------------------------------------------------------------- /docs/contrib/local-actions.md: -------------------------------------------------------------------------------- 1 | # act 2 | 3 | Run your [GitHub Actions](https://developer.github.com/actions/) locally! Why would you want to do this? Two reasons: 4 | 5 | - **Fast Feedback** - Rather than having to commit/push every time you want to test out the changes you are making to your `.github/workflows/` files (or for any changes to embedded GitHub actions), you can use `act` to run the actions locally. The [environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) and [filesystem](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners) are all configured to match what GitHub provides. 6 | - **Local Task Runner** - I love [make](https://en.wikipedia.org/wiki/Make_(software)). However, I also hate repeating myself. With `act`, you can use the GitHub Actions defined in your `.github/workflows/` to replace your `Makefile`! 7 | 8 | ## install act 9 | 10 | + [https://github.com/nektos/act](https://github.com/nektos/act) 11 | 12 | ```bash 13 | curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash 14 | ··· -------------------------------------------------------------------------------- /docs/contrib/util-go.md: -------------------------------------------------------------------------------- 1 | # utils go 2 | 3 | + [toold readme](https://github.com/openimsdk/open-im-server/tree/main/tools) 4 | 5 | about scripts fix: 6 | ``` 7 | "${OPENIM-ROOT}/_output/bin/tools/${platform}/${lookfor}" 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/images/architecture-layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/architecture-layers.png -------------------------------------------------------------------------------- /docs/images/architecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/architecture.jpg -------------------------------------------------------------------------------- /docs/images/oepnim-design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/oepnim-design.png -------------------------------------------------------------------------------- /docs/images/open-im-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/open-im-logo.png -------------------------------------------------------------------------------- /docs/images/open-im-server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/open-im-server.png -------------------------------------------------------------------------------- /docs/images/wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/docs/images/wechat.jpg -------------------------------------------------------------------------------- /internal/api/custom_validator.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "github.com/go-playground/validator/v10" 19 | "github.com/openimsdk/protocol/constant" 20 | ) 21 | 22 | // RequiredIf validates if the specified field is required based on the session type. 23 | func RequiredIf(fl validator.FieldLevel) bool { 24 | sessionType := fl.Parent().FieldByName("SessionType").Int() 25 | 26 | switch sessionType { 27 | case constant.SingleChatType, constant.NotificationChatType: 28 | return fl.FieldName() != "RecvID" || fl.Field().String() != "" 29 | case constant.WriteGroupChatType, constant.ReadGroupChatType: 30 | return fl.FieldName() != "GroupID" || fl.Field().String() != "" 31 | default: 32 | return true 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /internal/api/jssdk/sort.go: -------------------------------------------------------------------------------- 1 | package jssdk 2 | 3 | import "github.com/openimsdk/protocol/msg" 4 | 5 | type sortActiveConversations struct { 6 | Conversation []*msg.ActiveConversation 7 | PinnedConversationIDs map[string]struct{} 8 | } 9 | 10 | func (s sortActiveConversations) Top(limit int) []*msg.ActiveConversation { 11 | if limit > 0 && len(s.Conversation) > limit { 12 | return s.Conversation[:limit] 13 | } 14 | return s.Conversation 15 | } 16 | 17 | func (s sortActiveConversations) Len() int { 18 | return len(s.Conversation) 19 | } 20 | 21 | func (s sortActiveConversations) Less(i, j int) bool { 22 | iv, jv := s.Conversation[i], s.Conversation[j] 23 | _, ip := s.PinnedConversationIDs[iv.ConversationID] 24 | _, jp := s.PinnedConversationIDs[jv.ConversationID] 25 | if ip != jp { 26 | return ip 27 | } 28 | return iv.LastTime > jv.LastTime 29 | } 30 | 31 | func (s sortActiveConversations) Swap(i, j int) { 32 | s.Conversation[i], s.Conversation[j] = s.Conversation[j], s.Conversation[i] 33 | } 34 | -------------------------------------------------------------------------------- /internal/msggateway/http_error.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package msggateway 16 | 17 | import ( 18 | "github.com/openimsdk/tools/apiresp" 19 | "github.com/openimsdk/tools/log" 20 | ) 21 | 22 | func httpError(ctx *UserConnContext, err error) { 23 | log.ZWarn(ctx, "ws connection error", err) 24 | apiresp.HttpError(ctx.RespWriter, err) 25 | } 26 | -------------------------------------------------------------------------------- /internal/push/offlinepush/dummy/push.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dummy 16 | 17 | import ( 18 | "context" 19 | "github.com/openimsdk/open-im-server/v3/internal/push/offlinepush/options" 20 | "github.com/openimsdk/tools/log" 21 | "sync/atomic" 22 | ) 23 | 24 | func NewClient() *Dummy { 25 | return &Dummy{} 26 | } 27 | 28 | type Dummy struct { 29 | v atomic.Bool 30 | } 31 | 32 | func (d *Dummy) Push(ctx context.Context, userIDs []string, title, content string, opts *options.Opts) error { 33 | if d.v.CompareAndSwap(false, true) { 34 | log.ZWarn(ctx, "dummy push", nil, "ps", "the offline push is not configured. to configure it, please go to config/openim-push.yml") 35 | } 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /internal/push/offlinepush/jpush/body/message.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package body 16 | 17 | type Message struct { 18 | MsgContent string `json:"msg_content"` 19 | Title string `json:"title,omitempty"` 20 | ContentType string `json:"content_type,omitempty"` 21 | Extras map[string]any `json:"extras,omitempty"` 22 | } 23 | 24 | func (m *Message) SetMsgContent(c string) { 25 | m.MsgContent = c 26 | } 27 | 28 | func (m *Message) SetTitle(t string) { 29 | m.Title = t 30 | } 31 | 32 | func (m *Message) SetContentType(c string) { 33 | m.ContentType = c 34 | } 35 | 36 | func (m *Message) SetExtras(key string, value any) { 37 | if m.Extras == nil { 38 | m.Extras = make(map[string]any) 39 | } 40 | m.Extras[key] = value 41 | } 42 | -------------------------------------------------------------------------------- /internal/push/offlinepush/jpush/body/options.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package body 16 | 17 | type Options struct { 18 | ApnsProduction bool `json:"apns_production"` 19 | } 20 | 21 | func (o *Options) SetApnsProduction(c bool) { 22 | o.ApnsProduction = c 23 | } 24 | -------------------------------------------------------------------------------- /internal/push/offlinepush/jpush/body/pushobj.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package body 16 | 17 | type PushObj struct { 18 | Platform any `json:"platform"` 19 | Audience any `json:"audience"` 20 | Notification any `json:"notification,omitempty"` 21 | Message any `json:"message,omitempty"` 22 | Options any `json:"options,omitempty"` 23 | } 24 | 25 | func (p *PushObj) SetPlatform(pf *Platform) { 26 | p.Platform = pf.Os 27 | } 28 | 29 | func (p *PushObj) SetAudience(ad *Audience) { 30 | p.Audience = ad.Object 31 | } 32 | 33 | func (p *PushObj) SetNotification(no *Notification) { 34 | p.Notification = no 35 | } 36 | 37 | func (p *PushObj) SetMessage(m *Message) { 38 | p.Message = m 39 | } 40 | 41 | func (p *PushObj) SetOptions(o *Options) { 42 | p.Options = o 43 | } 44 | -------------------------------------------------------------------------------- /internal/push/offlinepush/options/options.go: -------------------------------------------------------------------------------- 1 | package options 2 | 3 | // Opts opts. 4 | type Opts struct { 5 | Signal *Signal 6 | IOSPushSound string 7 | IOSBadgeCount bool 8 | Ex string 9 | } 10 | 11 | // Signal message id. 12 | type Signal struct { 13 | ClientMsgID string 14 | } 15 | -------------------------------------------------------------------------------- /internal/rpc/group/fill.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package group 16 | 17 | import ( 18 | "context" 19 | 20 | relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 21 | ) 22 | 23 | func (g *groupServer) PopulateGroupMember(ctx context.Context, members ...*relationtb.GroupMember) error { 24 | return g.notification.PopulateGroupMember(ctx, members...) 25 | } 26 | -------------------------------------------------------------------------------- /internal/tools/cron/msg.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "github.com/openimsdk/protocol/msg" 9 | "github.com/openimsdk/tools/log" 10 | "github.com/openimsdk/tools/mcontext" 11 | ) 12 | 13 | func (c *cronServer) deleteMsg() { 14 | now := time.Now() 15 | deltime := now.Add(-time.Hour * 24 * time.Duration(c.config.CronTask.RetainChatRecords)) 16 | operationID := fmt.Sprintf("cron_msg_%d_%d", os.Getpid(), deltime.UnixMilli()) 17 | ctx := mcontext.SetOperationID(c.ctx, operationID) 18 | log.ZDebug(ctx, "Destruct chat records", "deltime", deltime, "timestamp", deltime.UnixMilli()) 19 | const ( 20 | deleteCount = 10000 21 | deleteLimit = 50 22 | ) 23 | var count int 24 | for i := 1; i <= deleteCount; i++ { 25 | ctx := mcontext.SetOperationID(c.ctx, fmt.Sprintf("%s_%d", operationID, i)) 26 | resp, err := c.msgClient.DestructMsgs(ctx, &msg.DestructMsgsReq{Timestamp: deltime.UnixMilli(), Limit: deleteLimit}) 27 | if err != nil { 28 | log.ZError(ctx, "cron destruct chat records failed", err) 29 | break 30 | } 31 | count += int(resp.Count) 32 | if resp.Count < deleteLimit { 33 | break 34 | } 35 | } 36 | log.ZDebug(ctx, "cron destruct chat records end", "deltime", deltime, "cont", time.Since(now), "count", count) 37 | } 38 | -------------------------------------------------------------------------------- /internal/tools/cron/user_msg.go: -------------------------------------------------------------------------------- 1 | package cron 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | pbconversation "github.com/openimsdk/protocol/conversation" 9 | "github.com/openimsdk/tools/log" 10 | "github.com/openimsdk/tools/mcontext" 11 | ) 12 | 13 | func (c *cronServer) clearUserMsg() { 14 | now := time.Now() 15 | operationID := fmt.Sprintf("cron_user_msg_%d_%d", os.Getpid(), now.UnixMilli()) 16 | ctx := mcontext.SetOperationID(c.ctx, operationID) 17 | log.ZDebug(ctx, "clear user msg cron start") 18 | const ( 19 | deleteCount = 10000 20 | deleteLimit = 100 21 | ) 22 | var count int 23 | for i := 1; i <= deleteCount; i++ { 24 | resp, err := c.conversationClient.ClearUserConversationMsg(ctx, &pbconversation.ClearUserConversationMsgReq{Timestamp: now.UnixMilli(), Limit: deleteLimit}) 25 | if err != nil { 26 | log.ZError(ctx, "ClearUserConversationMsg failed.", err) 27 | return 28 | } 29 | count += int(resp.Count) 30 | if resp.Count < deleteLimit { 31 | break 32 | } 33 | } 34 | log.ZDebug(ctx, "clear user msg cron task completed", "cont", time.Since(now), "count", count) 35 | } 36 | -------------------------------------------------------------------------------- /magefile.go: -------------------------------------------------------------------------------- 1 | //go:build mage 2 | // +build mage 3 | 4 | package main 5 | 6 | import ( 7 | "flag" 8 | "os" 9 | 10 | "github.com/openimsdk/gomake/mageutil" 11 | ) 12 | 13 | var Default = Build 14 | 15 | func Build() { 16 | flag.Parse() 17 | 18 | bin := flag.Args() 19 | if len(bin) != 0 { 20 | bin = bin[1:] 21 | } 22 | 23 | mageutil.Build(bin) 24 | } 25 | 26 | func Start() { 27 | mageutil.InitForSSC() 28 | err := setMaxOpenFiles() 29 | if err != nil { 30 | mageutil.PrintRed("setMaxOpenFiles failed " + err.Error()) 31 | os.Exit(1) 32 | } 33 | mageutil.StartToolsAndServices() 34 | } 35 | 36 | func Stop() { 37 | mageutil.StopAndCheckBinaries() 38 | } 39 | 40 | func Check() { 41 | mageutil.CheckAndReportBinariesStatus() 42 | } 43 | -------------------------------------------------------------------------------- /magefile_unix.go: -------------------------------------------------------------------------------- 1 | //go:build mage && !windows 2 | // +build mage,!windows 3 | 4 | package main 5 | 6 | import ( 7 | "syscall" 8 | 9 | "github.com/openimsdk/gomake/mageutil" 10 | ) 11 | 12 | func setMaxOpenFiles() error { 13 | var rLimit syscall.Rlimit 14 | err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) 15 | if err != nil { 16 | return err 17 | } 18 | rLimit.Max = uint64(mageutil.MaxFileDescriptors) 19 | rLimit.Cur = uint64(mageutil.MaxFileDescriptors) 20 | return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) 21 | } 22 | -------------------------------------------------------------------------------- /magefile_windows.go: -------------------------------------------------------------------------------- 1 | //go:build mage 2 | // +build mage 3 | 4 | package main 5 | 6 | func setMaxOpenFiles() error { 7 | return nil 8 | } 9 | -------------------------------------------------------------------------------- /pkg/apistruct/config_manager.go: -------------------------------------------------------------------------------- 1 | package apistruct 2 | 3 | type GetConfigReq struct { 4 | ConfigName string `json:"configName"` 5 | } 6 | 7 | type GetConfigListResp struct { 8 | Environment string `json:"environment"` 9 | Version string `json:"version"` 10 | ConfigNames []string `json:"configNames"` 11 | } 12 | 13 | type SetConfigReq struct { 14 | ConfigName string `json:"configName"` 15 | Data string `json:"data"` 16 | } 17 | 18 | type SetConfigsReq struct { 19 | Configs []SetConfigReq `json:"configs"` 20 | } 21 | 22 | type SetEnableConfigManagerReq struct { 23 | Enable bool `json:"enable"` 24 | } 25 | 26 | type GetEnableConfigManagerResp struct { 27 | Enable bool `json:"enable"` 28 | } 29 | -------------------------------------------------------------------------------- /pkg/apistruct/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package apistruct // import "github.com/openimsdk/open-im-server/v3/pkg/apistruct" 16 | -------------------------------------------------------------------------------- /pkg/apistruct/public.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package apistruct 16 | 17 | type GroupAddMemberInfo struct { 18 | UserID string `json:"userID" binding:"required"` 19 | RoleLevel int32 `json:"roleLevel" binding:"required,oneof= 1 3"` 20 | } 21 | -------------------------------------------------------------------------------- /pkg/authverify/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package authverify // import "github.com/openimsdk/open-im-server/v3/pkg/authverify" 16 | -------------------------------------------------------------------------------- /pkg/callbackstruct/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package callbackstruct // import "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" 16 | -------------------------------------------------------------------------------- /pkg/callbackstruct/revoke.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package callbackstruct 16 | 17 | type CallbackAfterRevokeMsgReq struct { 18 | CallbackCommand `json:"callbackCommand"` 19 | ConversationID string `json:"conversationID"` 20 | Seq int64 `json:"seq"` 21 | UserID string `json:"userID"` 22 | } 23 | 24 | type CallbackAfterRevokeMsgResp struct { 25 | CommonCallbackResp 26 | } 27 | -------------------------------------------------------------------------------- /pkg/common/cmd/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd // import "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" 16 | -------------------------------------------------------------------------------- /pkg/common/config/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config // import "github.com/openimsdk/open-im-server/v3/pkg/common/config" 16 | -------------------------------------------------------------------------------- /pkg/common/config/env.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "strings" 4 | 5 | var EnvPrefixMap map[string]string 6 | 7 | func init() { 8 | EnvPrefixMap = make(map[string]string) 9 | fileNames := []string{ 10 | FileName, NotificationFileName, ShareFileName, WebhooksConfigFileName, 11 | KafkaConfigFileName, RedisConfigFileName, 12 | MongodbConfigFileName, MinioConfigFileName, LogConfigFileName, 13 | OpenIMAPICfgFileName, OpenIMCronTaskCfgFileName, OpenIMMsgGatewayCfgFileName, 14 | OpenIMMsgTransferCfgFileName, OpenIMPushCfgFileName, OpenIMRPCAuthCfgFileName, 15 | OpenIMRPCConversationCfgFileName, OpenIMRPCFriendCfgFileName, OpenIMRPCGroupCfgFileName, 16 | OpenIMRPCMsgCfgFileName, OpenIMRPCThirdCfgFileName, OpenIMRPCUserCfgFileName, DiscoveryConfigFilename, 17 | } 18 | 19 | for _, fileName := range fileNames { 20 | envKey := strings.TrimSuffix(strings.TrimSuffix(fileName, ".yml"), ".yaml") 21 | envKey = "IMENV_" + envKey 22 | envKey = strings.ToUpper(strings.ReplaceAll(envKey, "-", "_")) 23 | EnvPrefixMap[fileName] = envKey 24 | } 25 | } 26 | 27 | const ( 28 | FlagConf = "config_folder_path" 29 | FlagTransferIndex = "index" 30 | ) 31 | -------------------------------------------------------------------------------- /pkg/common/config/global.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | var standalone bool 4 | 5 | func SetStandalone() { 6 | standalone = true 7 | } 8 | 9 | func Standalone() bool { 10 | return standalone 11 | } 12 | -------------------------------------------------------------------------------- /pkg/common/convert/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package convert // import "github.com/openimsdk/open-im-server/v3/pkg/common/convert" 16 | -------------------------------------------------------------------------------- /pkg/common/discovery/direct/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package direct // import "github.com/openimsdk/open-im-server/v3/pkg/common/discovery/direct" 16 | -------------------------------------------------------------------------------- /pkg/common/discovery/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package discovery // import "github.com/openimsdk/open-im-server/v3/pkg/common/discovery" 16 | -------------------------------------------------------------------------------- /pkg/common/discovery/etcd/const.go: -------------------------------------------------------------------------------- 1 | package etcd 2 | 3 | const ( 4 | ConfigKeyPrefix = "/open-im/config/" 5 | RestartKey = "restart" 6 | EnableConfigCenterKey = "enable-config-center" 7 | Enable = "enable" 8 | Disable = "disable" 9 | ) 10 | -------------------------------------------------------------------------------- /pkg/common/discovery/kubernetes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package kubernetes // import "github.com/openimsdk/open-im-server/v3/pkg/common/discovery/kubernetes" 16 | -------------------------------------------------------------------------------- /pkg/common/ginprometheus/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ginprometheus // import "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus" 16 | -------------------------------------------------------------------------------- /pkg/common/prommetrics/api.go: -------------------------------------------------------------------------------- 1 | package prommetrics 2 | 3 | import ( 4 | "net" 5 | "strconv" 6 | 7 | "github.com/prometheus/client_golang/prometheus" 8 | "github.com/prometheus/client_golang/prometheus/promhttp" 9 | ) 10 | 11 | var ( 12 | apiCounter = prometheus.NewCounterVec( 13 | prometheus.CounterOpts{ 14 | Name: "api_count", 15 | Help: "Total number of API calls", 16 | }, 17 | []string{"path", "method", "code"}, 18 | ) 19 | httpCounter = prometheus.NewCounterVec( 20 | prometheus.CounterOpts{ 21 | Name: "http_count", 22 | Help: "Total number of HTTP calls", 23 | }, 24 | []string{"path", "method", "status"}, 25 | ) 26 | ) 27 | 28 | func RegistryApi() { 29 | registry.MustRegister(apiCounter, httpCounter) 30 | } 31 | 32 | func ApiInit(listener net.Listener) error { 33 | apiRegistry := prometheus.NewRegistry() 34 | cs := append( 35 | baseCollector, 36 | apiCounter, 37 | httpCounter, 38 | ) 39 | return Init(apiRegistry, listener, commonPath, promhttp.HandlerFor(apiRegistry, promhttp.HandlerOpts{}), cs...) 40 | } 41 | 42 | func APICall(path string, method string, apiCode int) { 43 | apiCounter.With(prometheus.Labels{"path": path, "method": method, "code": strconv.Itoa(apiCode)}).Inc() 44 | } 45 | 46 | func HttpCall(path string, method string, status int) { 47 | httpCounter.With(prometheus.Labels{"path": path, "method": method, "status": strconv.Itoa(status)}).Inc() 48 | } 49 | -------------------------------------------------------------------------------- /pkg/common/prommetrics/grpc_auth.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package prommetrics 16 | 17 | import ( 18 | "github.com/prometheus/client_golang/prometheus" 19 | ) 20 | 21 | var ( 22 | UserLoginCounter = prometheus.NewCounter(prometheus.CounterOpts{ 23 | Name: "user_login_total", 24 | Help: "The number of user login", 25 | }) 26 | ) 27 | 28 | func RegistryAuth() { 29 | registry.MustRegister(UserLoginCounter) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/common/prommetrics/grpc_msggateway.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package prommetrics 16 | 17 | import ( 18 | "github.com/prometheus/client_golang/prometheus" 19 | ) 20 | 21 | var ( 22 | OnlineUserGauge = prometheus.NewGauge(prometheus.GaugeOpts{ 23 | Name: "online_user_num", 24 | Help: "The number of online user num", 25 | }) 26 | ) 27 | 28 | func RegistryMsgGateway() { 29 | registry.MustRegister(OnlineUserGauge) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/common/prommetrics/grpc_push.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package prommetrics 16 | 17 | import ( 18 | "github.com/prometheus/client_golang/prometheus" 19 | ) 20 | 21 | var ( 22 | MsgOfflinePushFailedCounter = prometheus.NewCounter(prometheus.CounterOpts{ 23 | Name: "msg_offline_push_failed_total", 24 | Help: "The number of msg failed offline pushed", 25 | }) 26 | MsgLoneTimePushCounter = prometheus.NewCounter(prometheus.CounterOpts{ 27 | Name: "msg_long_time_push_total", 28 | Help: "The number of messages with a push time exceeding 10 seconds", 29 | }) 30 | ) 31 | 32 | func RegistryPush() { 33 | registry.MustRegister( 34 | MsgOfflinePushFailedCounter, 35 | MsgLoneTimePushCounter, 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/common/prommetrics/grpc_user.go: -------------------------------------------------------------------------------- 1 | package prommetrics 2 | 3 | import "github.com/prometheus/client_golang/prometheus" 4 | 5 | var ( 6 | UserRegisterCounter = prometheus.NewCounter(prometheus.CounterOpts{ 7 | Name: "user_register_total", 8 | Help: "The number of user login", 9 | }) 10 | ) 11 | 12 | func RegistryUser() { 13 | registry.MustRegister(UserRegisterCounter) 14 | } 15 | -------------------------------------------------------------------------------- /pkg/common/servererrs/doc.go: -------------------------------------------------------------------------------- 1 | package servererrs // import "github.com/openimsdk/open-im-server/v3/pkg/common/servererrs" 2 | -------------------------------------------------------------------------------- /pkg/common/startrpc/mw.go: -------------------------------------------------------------------------------- 1 | package startrpc 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/openimsdk/open-im-server/v3/pkg/authverify" 7 | "google.golang.org/grpc" 8 | ) 9 | 10 | func grpcServerIMAdminUserID(imAdminUserID []string) grpc.ServerOption { 11 | return grpc.ChainUnaryInterceptor(func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { 12 | ctx = authverify.WithIMAdminUserIDs(ctx, imAdminUserID) 13 | return handler(ctx, req) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /pkg/common/startrpc/tools.go: -------------------------------------------------------------------------------- 1 | package startrpc 2 | 3 | import ( 4 | "reflect" 5 | 6 | conf "github.com/openimsdk/open-im-server/v3/pkg/common/config" 7 | ) 8 | 9 | func getConfig[T any](value reflect.Value) *T { 10 | for value.Kind() == reflect.Pointer { 11 | value = value.Elem() 12 | } 13 | if value.Kind() == reflect.Struct { 14 | num := value.NumField() 15 | for i := 0; i < num; i++ { 16 | field := value.Field(i) 17 | for field.Kind() == reflect.Pointer { 18 | field = field.Elem() 19 | } 20 | if field.Kind() == reflect.Struct { 21 | if elem, ok := field.Interface().(T); ok { 22 | return &elem 23 | } 24 | if elem := getConfig[T](field); elem != nil { 25 | return elem 26 | } 27 | } 28 | } 29 | } 30 | return nil 31 | } 32 | 33 | func getConfigRpcMaxRequestBody(value reflect.Value) *conf.MaxRequestBody { 34 | return getConfig[conf.MaxRequestBody](value) 35 | } 36 | 37 | func getConfigShare(value reflect.Value) *conf.Share { 38 | return getConfig[conf.Share](value) 39 | } 40 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/batch_handler.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | // BatchDeleter interface defines a set of methods for batch deleting cache and publishing deletion information. 8 | type BatchDeleter interface { 9 | //ChainExecDel method is used for chain calls and must call Clone to prevent memory pollution. 10 | ChainExecDel(ctx context.Context) error 11 | //ExecDelWithKeys method directly takes keys for deletion. 12 | ExecDelWithKeys(ctx context.Context, keys []string) error 13 | //Clone method creates a copy of the BatchDeleter to avoid modifying the original object. 14 | Clone() BatchDeleter 15 | //AddKeys method adds keys to be deleted. 16 | AddKeys(keys ...string) 17 | } 18 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/black.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache 16 | 17 | import ( 18 | "context" 19 | ) 20 | 21 | type BlackCache interface { 22 | BatchDeleter 23 | CloneBlackCache() BlackCache 24 | GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) 25 | // del user's blackIDs msgCache, exec when a user's black list changed 26 | DelBlackIDs(ctx context.Context, userID string) BlackCache 27 | } 28 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/black.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey 16 | 17 | const ( 18 | BlackIDsKey = "BLACK_IDS:" 19 | IsBlackKey = "IS_BLACK:" // local cache 20 | ) 21 | 22 | func GetBlackIDsKey(ownerUserID string) string { 23 | return BlackIDsKey + ownerUserID 24 | 25 | } 26 | 27 | func GetIsBlackIDsKey(possibleBlackUserID, userID string) string { 28 | return IsBlackKey + userID + "-" + possibleBlackUserID 29 | } 30 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/client_config.go: -------------------------------------------------------------------------------- 1 | package cachekey 2 | 3 | const ClientConfig = "CLIENT_CONFIG" 4 | 5 | func GetClientConfigKey(userID string) string { 6 | if userID == "" { 7 | return ClientConfig 8 | } 9 | return ClientConfig + ":" + userID 10 | } 11 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cachekey" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/msg.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey 16 | 17 | import ( 18 | "strconv" 19 | ) 20 | 21 | const ( 22 | sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:" 23 | messageCache = "MSG_CACHE:" 24 | ) 25 | 26 | func GetMsgCacheKey(conversationID string, seq int64) string { 27 | return messageCache + conversationID + ":" + strconv.Itoa(int(seq)) 28 | } 29 | 30 | func GetSendMsgKey(id string) string { 31 | return sendMsgFailedFlag + id 32 | } 33 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/online.go: -------------------------------------------------------------------------------- 1 | package cachekey 2 | 3 | import ( 4 | "strings" 5 | "time" 6 | ) 7 | 8 | const ( 9 | OnlineKey = "ONLINE:" 10 | OnlineChannel = "online_change" 11 | OnlineExpire = time.Hour / 2 12 | ) 13 | 14 | func GetOnlineKey(userID string) string { 15 | return OnlineKey + userID 16 | } 17 | 18 | func GetOnlineKeyUserID(key string) string { 19 | return strings.TrimPrefix(key, OnlineKey) 20 | } 21 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/s3.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey 16 | 17 | import "strconv" 18 | 19 | const ( 20 | object = "OBJECT:" 21 | s3 = "S3:" 22 | minioImageInfo = "MINIO:IMAGE:" 23 | minioThumbnail = "MINIO:THUMBNAIL:" 24 | ) 25 | 26 | func GetObjectKey(engine string, name string) string { 27 | return object + engine + ":" + name 28 | } 29 | 30 | func GetS3Key(engine string, name string) string { 31 | return s3 + engine + ":" + name 32 | } 33 | 34 | func GetObjectImageInfoKey(key string) string { 35 | return minioImageInfo + key 36 | } 37 | 38 | func GetMinioImageThumbnailKey(key string, format string, width int, height int) string { 39 | return minioThumbnail + format + ":w" + strconv.Itoa(width) + ":h" + strconv.Itoa(height) + ":" + key 40 | } 41 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/seq.go: -------------------------------------------------------------------------------- 1 | package cachekey 2 | 3 | const ( 4 | MallocSeq = "MALLOC_SEQ:" 5 | MallocMinSeqLock = "MALLOC_MIN_SEQ:" 6 | 7 | SeqUserMaxSeq = "SEQ_USER_MAX:" 8 | SeqUserMinSeq = "SEQ_USER_MIN:" 9 | SeqUserReadSeq = "SEQ_USER_READ:" 10 | ) 11 | 12 | func GetMallocSeqKey(conversationID string) string { 13 | return MallocSeq + conversationID 14 | } 15 | 16 | func GetMallocMinSeqKey(conversationID string) string { 17 | return MallocMinSeqLock + conversationID 18 | } 19 | 20 | func GetSeqUserMaxSeqKey(conversationID string, userID string) string { 21 | return SeqUserMaxSeq + conversationID + ":" + userID 22 | } 23 | 24 | func GetSeqUserMinSeqKey(conversationID string, userID string) string { 25 | return SeqUserMinSeq + conversationID + ":" + userID 26 | } 27 | 28 | func GetSeqUserReadSeqKey(conversationID string, userID string) string { 29 | return SeqUserReadSeq + conversationID + ":" + userID 30 | } 31 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/third.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey 16 | 17 | import ( 18 | "strconv" 19 | ) 20 | 21 | const ( 22 | getuiToken = "GETUI_TOKEN" 23 | getuiTaskID = "GETUI_TASK_ID" 24 | fmcToken = "FCM_TOKEN:" 25 | userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:" 26 | ) 27 | 28 | func GetFcmAccountTokenKey(account string, platformID int) string { 29 | return fmcToken + account + ":" + strconv.Itoa(platformID) 30 | } 31 | 32 | func GetUserBadgeUnreadCountSumKey(userID string) string { 33 | return userBadgeUnreadCountSum + userID 34 | } 35 | 36 | func GetGetuiTokenKey() string { 37 | return getuiToken 38 | } 39 | func GetGetuiTaskIDKey() string { 40 | return getuiTaskID 41 | } 42 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/token.go: -------------------------------------------------------------------------------- 1 | package cachekey 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/openimsdk/protocol/constant" 7 | ) 8 | 9 | const ( 10 | UidPidToken = "UID_PID_TOKEN_STATUS:" 11 | ) 12 | 13 | func GetTokenKey(userID string, platformID int) string { 14 | return UidPidToken + userID + ":" + constant.PlatformIDToName(platformID) 15 | } 16 | 17 | func GetTemporaryTokenKey(userID string, platformID int, token string) string { 18 | return UidPidToken + ":TEMPORARY:" + userID + ":" + constant.PlatformIDToName(platformID) + ":" + token 19 | } 20 | 21 | func GetAllPlatformTokenKey(userID string) []string { 22 | res := make([]string, len(constant.PlatformID2Name)) 23 | for k := range constant.PlatformID2Name { 24 | res[k-1] = GetTokenKey(userID, k) 25 | } 26 | return res 27 | } 28 | 29 | func GetPlatformIDByTokenKey(key string) int { 30 | splitKey := strings.Split(key, ":") 31 | platform := splitKey[len(splitKey)-1] 32 | return constant.PlatformNameToID(platform) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/cachekey/user.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cachekey 16 | 17 | const ( 18 | UserInfoKey = "USER_INFO:" 19 | UserGlobalRecvMsgOptKey = "USER_GLOBAL_RECV_MSG_OPT_KEY:" 20 | ) 21 | 22 | func GetUserInfoKey(userID string) string { 23 | return UserInfoKey + userID 24 | } 25 | 26 | func GetUserGlobalRecvMsgOptKey(userID string) string { 27 | return UserGlobalRecvMsgOptKey + userID 28 | } 29 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/client_config.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "context" 4 | 5 | type ClientConfigCache interface { 6 | DeleteUserCache(ctx context.Context, userIDs []string) error 7 | GetUserConfig(ctx context.Context, userID string) (map[string]string, error) 8 | } 9 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/msg.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache 16 | 17 | import ( 18 | "context" 19 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 20 | ) 21 | 22 | type MsgCache interface { 23 | SetSendMsgStatus(ctx context.Context, id string, status int32) error 24 | GetSendMsgStatus(ctx context.Context, id string) (int32, error) 25 | 26 | GetMessageBySeqs(ctx context.Context, conversationID string, seqs []int64) ([]*model.MsgInfoModel, error) 27 | DelMessageBySeqs(ctx context.Context, conversationID string, seqs []int64) error 28 | SetMessageBySeqs(ctx context.Context, conversationID string, msgs []*model.MsgInfoModel) error 29 | } 30 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/online.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "context" 4 | 5 | type OnlineCache interface { 6 | GetOnline(ctx context.Context, userID string) ([]int32, error) 7 | SetUserOnline(ctx context.Context, userID string, online, offline []int32) error 8 | GetAllOnlineUsers(ctx context.Context, cursor uint64) (map[string][]int32, uint64, error) 9 | } 10 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/redis/online_test.go: -------------------------------------------------------------------------------- 1 | package redis 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/open-im-server/v3/pkg/common/config" 6 | "github.com/openimsdk/tools/db/redisutil" 7 | "testing" 8 | "time" 9 | ) 10 | 11 | /* 12 | address: [ 172.16.8.48:7001, 172.16.8.48:7002, 172.16.8.48:7003, 172.16.8.48:7004, 172.16.8.48:7005, 172.16.8.48:7006 ] 13 | username: 14 | password: passwd123 15 | clusterMode: true 16 | db: 0 17 | maxRetry: 10 18 | */ 19 | func TestName111111(t *testing.T) { 20 | conf := config.Redis{ 21 | Address: []string{ 22 | "172.16.8.124:7001", 23 | "172.16.8.124:7002", 24 | "172.16.8.124:7003", 25 | "172.16.8.124:7004", 26 | "172.16.8.124:7005", 27 | "172.16.8.124:7006", 28 | }, 29 | ClusterMode: true, 30 | Password: "passwd123", 31 | //Address: []string{"localhost:16379"}, 32 | //Password: "openIM123", 33 | } 34 | ctx, cancel := context.WithTimeout(context.Background(), time.Second*1000) 35 | defer cancel() 36 | rdb, err := redisutil.NewRedisClient(ctx, conf.Build()) 37 | if err != nil { 38 | panic(err) 39 | } 40 | online := NewUserOnline(rdb) 41 | 42 | userID := "a123456" 43 | t.Log(online.GetOnline(ctx, userID)) 44 | t.Log(online.SetUserOnline(ctx, userID, []int32{1, 2, 3, 4}, nil)) 45 | t.Log(online.GetOnline(ctx, userID)) 46 | 47 | } 48 | 49 | func TestName111(t *testing.T) { 50 | 51 | } 52 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/seq_conversation.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" 6 | ) 7 | 8 | type SeqConversationCache interface { 9 | Malloc(ctx context.Context, conversationID string, size int64) (int64, error) 10 | GetMaxSeq(ctx context.Context, conversationID string) (int64, error) 11 | SetMinSeq(ctx context.Context, conversationID string, seq int64) error 12 | GetMinSeq(ctx context.Context, conversationID string) (int64, error) 13 | GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) 14 | SetMinSeqs(ctx context.Context, seqs map[string]int64) error 15 | GetCacheMaxSeqWithTime(ctx context.Context, conversationIDs []string) (map[string]database.SeqTime, error) 16 | GetMaxSeqsWithTime(ctx context.Context, conversationIDs []string) (map[string]database.SeqTime, error) 17 | GetMaxSeqWithTime(ctx context.Context, conversationID string) (database.SeqTime, error) 18 | } 19 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/seq_user.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "context" 4 | 5 | type SeqUser interface { 6 | GetUserMaxSeq(ctx context.Context, conversationID string, userID string) (int64, error) 7 | SetUserMaxSeq(ctx context.Context, conversationID string, userID string, seq int64) error 8 | GetUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) 9 | SetUserMinSeq(ctx context.Context, conversationID string, userID string, seq int64) error 10 | GetUserReadSeq(ctx context.Context, conversationID string, userID string) (int64, error) 11 | SetUserReadSeq(ctx context.Context, conversationID string, userID string, seq int64) error 12 | SetUserReadSeqToDB(ctx context.Context, conversationID string, userID string, seq int64) error 13 | SetUserMinSeqs(ctx context.Context, userID string, seqs map[string]int64) error 14 | SetUserReadSeqs(ctx context.Context, userID string, seqs map[string]int64) error 15 | GetUserReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) 16 | } 17 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/third.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type ThirdCache interface { 8 | SetFcmToken(ctx context.Context, account string, platformID int, fcmToken string, expireTime int64) (err error) 9 | GetFcmToken(ctx context.Context, account string, platformID int) (string, error) 10 | DelFcmToken(ctx context.Context, account string, platformID int) error 11 | IncrUserBadgeUnreadCountSum(ctx context.Context, userID string) (int, error) 12 | SetUserBadgeUnreadCountSum(ctx context.Context, userID string, value int) error 13 | GetUserBadgeUnreadCountSum(ctx context.Context, userID string) (int, error) 14 | SetGetuiToken(ctx context.Context, token string, expireTime int64) error 15 | GetGetuiToken(ctx context.Context) (string, error) 16 | SetGetuiTaskID(ctx context.Context, taskID string, expireTime int64) error 17 | GetGetuiTaskID(ctx context.Context) (string, error) 18 | } 19 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/token.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type TokenModel interface { 8 | SetTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error 9 | // SetTokenFlagEx set token and flag with expire time 10 | SetTokenFlagEx(ctx context.Context, userID string, platformID int, token string, flag int) error 11 | GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error) 12 | HasTemporaryToken(ctx context.Context, userID string, platformID int, token string) error 13 | GetAllTokensWithoutError(ctx context.Context, userID string) (map[int]map[string]int, error) 14 | SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error 15 | BatchSetTokenMapByUidPid(ctx context.Context, tokens map[string]map[string]any) error 16 | DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error 17 | DeleteTokenByTokenMap(ctx context.Context, userID string, tokens map[int][]string) error 18 | DeleteAndSetTemporary(ctx context.Context, userID string, platformID int, fields []string) error 19 | } 20 | -------------------------------------------------------------------------------- /pkg/common/storage/cache/user.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cache 16 | 17 | import ( 18 | "context" 19 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 20 | ) 21 | 22 | type UserCache interface { 23 | BatchDeleter 24 | CloneUserCache() UserCache 25 | GetUserInfo(ctx context.Context, userID string) (userInfo *model.User, err error) 26 | GetUsersInfo(ctx context.Context, userIDs []string) ([]*model.User, error) 27 | DelUsersInfo(userIDs ...string) UserCache 28 | GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) 29 | DelUsersGlobalRecvMsgOpt(userIDs ...string) UserCache 30 | //GetUserStatus(ctx context.Context, userIDs []string) ([]*user.OnlineStatus, error) 31 | //SetUserStatus(ctx context.Context, userID string, status, platformID int32) error 32 | } 33 | -------------------------------------------------------------------------------- /pkg/common/storage/common/types.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package common 16 | 17 | type BatchUpdateGroupMember struct { 18 | GroupID string 19 | UserID string 20 | Map map[string]any 21 | } 22 | 23 | type GroupSimpleUserID struct { 24 | Hash uint64 25 | MemberNum uint32 26 | } 27 | -------------------------------------------------------------------------------- /pkg/common/storage/controller/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package controller // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/database/cache.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | "time" 6 | ) 7 | 8 | type Cache interface { 9 | Get(ctx context.Context, key []string) (map[string]string, error) 10 | Prefix(ctx context.Context, prefix string) (map[string]string, error) 11 | Set(ctx context.Context, key string, value string, expireAt time.Duration) error 12 | Incr(ctx context.Context, key string, value int) (int, error) 13 | Del(ctx context.Context, key []string) error 14 | Lock(ctx context.Context, key string, duration time.Duration) (string, error) 15 | Unlock(ctx context.Context, key string, value string) error 16 | } 17 | -------------------------------------------------------------------------------- /pkg/common/storage/database/client_config.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 7 | "github.com/openimsdk/tools/db/pagination" 8 | ) 9 | 10 | type ClientConfig interface { 11 | Set(ctx context.Context, userID string, config map[string]string) error 12 | Get(ctx context.Context, userID string) (map[string]string, error) 13 | Del(ctx context.Context, userID string, keys []string) error 14 | GetPage(ctx context.Context, userID string, key string, pagination pagination.Pagination) (int64, []*model.ClientConfig, error) 15 | } 16 | -------------------------------------------------------------------------------- /pkg/common/storage/database/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package database // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model/relation" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/database/log.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package database 16 | 17 | import ( 18 | "context" 19 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 20 | "github.com/openimsdk/tools/db/pagination" 21 | "time" 22 | ) 23 | 24 | type Log interface { 25 | Create(ctx context.Context, log []*model.Log) error 26 | Search(ctx context.Context, keyword string, start time.Time, end time.Time, pagination pagination.Pagination) (int64, []*model.Log, error) 27 | Delete(ctx context.Context, logID []string, userID string) error 28 | Get(ctx context.Context, logIDs []string, userID string) ([]*model.Log, error) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/common/storage/database/mgo/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package mgo // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/database/mgo/helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package mgo 16 | 17 | import ( 18 | "github.com/openimsdk/tools/errs" 19 | "go.mongodb.org/mongo-driver/mongo" 20 | ) 21 | 22 | func IsNotFound(err error) bool { 23 | return errs.Unwrap(err) == mongo.ErrNoDocuments 24 | } 25 | -------------------------------------------------------------------------------- /pkg/common/storage/database/mgo/seq_conversation_test.go: -------------------------------------------------------------------------------- 1 | package mgo 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | "time" 7 | 8 | "go.mongodb.org/mongo-driver/mongo" 9 | "go.mongodb.org/mongo-driver/mongo/options" 10 | ) 11 | 12 | func Result[V any](val V, err error) V { 13 | if err != nil { 14 | panic(err) 15 | } 16 | return val 17 | } 18 | 19 | func Mongodb() *mongo.Database { 20 | return Result( 21 | mongo.Connect(context.Background(), 22 | options.Client(). 23 | ApplyURI("mongodb://openIM:openIM123@172.16.8.135:37017/openim_v3?maxPoolSize=100"). 24 | SetConnectTimeout(5*time.Second)), 25 | ).Database("openim_v3") 26 | } 27 | 28 | func TestUserSeq(t *testing.T) { 29 | uSeq := Result(NewSeqUserMongo(Mongodb())).(*seqUserMongo) 30 | t.Log(uSeq.SetUserMinSeq(context.Background(), "1000", "2000", 4)) 31 | } 32 | 33 | func TestConversationSeq(t *testing.T) { 34 | cSeq := Result(NewSeqConversationMongo(Mongodb())).(*seqConversationMongo) 35 | t.Log(cSeq.SetMaxSeq(context.Background(), "2000", 10)) 36 | t.Log(cSeq.Malloc(context.Background(), "2000", 10)) 37 | t.Log(cSeq.GetMaxSeq(context.Background(), "2000")) 38 | } 39 | 40 | func TestUserGetUserReadSeqs(t *testing.T) { 41 | uSeq := Result(NewSeqUserMongo(Mongodb())).(*seqUserMongo) 42 | t.Log(uSeq.GetUserReadSeqs(context.Background(), "2110910952", []string{"sg_345762580", "2000", "3000"})) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/common/storage/database/mgo/version_test.go: -------------------------------------------------------------------------------- 1 | package mgo 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 6 | "go.mongodb.org/mongo-driver/mongo" 7 | "go.mongodb.org/mongo-driver/mongo/options" 8 | "testing" 9 | "time" 10 | ) 11 | 12 | //func Result[V any](val V, err error) V { 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // return val 17 | //} 18 | 19 | func Check(err error) { 20 | if err != nil { 21 | panic(err) 22 | } 23 | } 24 | 25 | func TestName(t *testing.T) { 26 | cli := Result(mongo.Connect(context.Background(), options.Client().ApplyURI("mongodb://openIM:openIM123@172.16.8.48:37017/openim_v3?maxPoolSize=100").SetConnectTimeout(5*time.Second))) 27 | coll := cli.Database("openim_v3").Collection("version_test") 28 | tmp, err := NewVersionLog(coll) 29 | if err != nil { 30 | panic(err) 31 | } 32 | vl := tmp.(*VersionLogMgo) 33 | res, err := vl.incrVersionResult(context.Background(), "100", []string{"1000", "1001", "1003"}, model.VersionStateInsert) 34 | if err != nil { 35 | t.Log(err) 36 | return 37 | } 38 | t.Logf("%+v", res) 39 | } 40 | -------------------------------------------------------------------------------- /pkg/common/storage/database/name.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | const ( 4 | BlackName = "black" 5 | ConversationName = "conversation" 6 | FriendName = "friend" 7 | FriendVersionName = "friend_version" 8 | FriendRequestName = "friend_request" 9 | GroupName = "group" 10 | GroupMemberName = "group_member" 11 | GroupMemberVersionName = "group_member_version" 12 | GroupJoinVersionName = "group_join_version" 13 | ConversationVersionName = "conversation_version" 14 | GroupRequestName = "group_request" 15 | LogName = "log" 16 | ObjectName = "s3" 17 | UserName = "user" 18 | SeqConversationName = "seq" 19 | SeqUserName = "seq_user" 20 | StreamMsgName = "stream_msg" 21 | CacheName = "cache" 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/common/storage/database/seq.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import "context" 4 | 5 | type SeqTime struct { 6 | Seq int64 7 | Time int64 8 | } 9 | 10 | type SeqConversation interface { 11 | Malloc(ctx context.Context, conversationID string, size int64) (int64, error) 12 | GetMaxSeq(ctx context.Context, conversationID string) (int64, error) 13 | SetMaxSeq(ctx context.Context, conversationID string, seq int64) error 14 | GetMinSeq(ctx context.Context, conversationID string) (int64, error) 15 | SetMinSeq(ctx context.Context, conversationID string, seq int64) error 16 | } 17 | -------------------------------------------------------------------------------- /pkg/common/storage/database/seq_user.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import "context" 4 | 5 | type SeqUser interface { 6 | GetUserMaxSeq(ctx context.Context, conversationID string, userID string) (int64, error) 7 | SetUserMaxSeq(ctx context.Context, conversationID string, userID string, seq int64) error 8 | GetUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) 9 | SetUserMinSeq(ctx context.Context, conversationID string, userID string, seq int64) error 10 | GetUserReadSeq(ctx context.Context, conversationID string, userID string) (int64, error) 11 | SetUserReadSeq(ctx context.Context, conversationID string, userID string, seq int64) error 12 | GetUserReadSeqs(ctx context.Context, userID string, conversationID []string) (map[string]int64, error) 13 | } 14 | -------------------------------------------------------------------------------- /pkg/common/storage/database/version_log.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 8 | ) 9 | 10 | const ( 11 | FirstVersion = 1 12 | DefaultDeleteVersion = 0 13 | ) 14 | 15 | type VersionLog interface { 16 | IncrVersion(ctx context.Context, dId string, eIds []string, state int32) error 17 | FindChangeLog(ctx context.Context, dId string, version uint, limit int) (*model.VersionLog, error) 18 | BatchFindChangeLog(ctx context.Context, dIds []string, versions []uint, limits []int) ([]*model.VersionLog, error) 19 | DeleteAfterUnchangedLog(ctx context.Context, deadline time.Time) error 20 | Delete(ctx context.Context, dId string) error 21 | } 22 | -------------------------------------------------------------------------------- /pkg/common/storage/model/application.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "go.mongodb.org/mongo-driver/bson/primitive" 5 | "time" 6 | ) 7 | 8 | type Application struct { 9 | ID primitive.ObjectID `bson:"_id"` 10 | Platform string `bson:"platform"` 11 | Hot bool `bson:"hot"` 12 | Version string `bson:"version"` 13 | Url string `bson:"url"` 14 | Text string `bson:"text"` 15 | Force bool `bson:"force"` 16 | Latest bool `bson:"latest"` 17 | CreateTime time.Time `bson:"create_time"` 18 | } 19 | -------------------------------------------------------------------------------- /pkg/common/storage/model/black.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type Black struct { 22 | OwnerUserID string `bson:"owner_user_id"` 23 | BlockUserID string `bson:"block_user_id"` 24 | CreateTime time.Time `bson:"create_time"` 25 | AddSource int32 `bson:"add_source"` 26 | OperatorUserID string `bson:"operator_user_id"` 27 | Ex string `bson:"ex"` 28 | } 29 | -------------------------------------------------------------------------------- /pkg/common/storage/model/cache.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "time" 4 | 5 | type Cache struct { 6 | Key string `bson:"key"` 7 | Value string `bson:"value"` 8 | ExpireAt *time.Time `bson:"expire_at"` 9 | } 10 | -------------------------------------------------------------------------------- /pkg/common/storage/model/client_config.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type ClientConfig struct { 4 | Key string `bson:"key"` 5 | UserID string `bson:"user_id"` 6 | Value string `bson:"value"` 7 | } 8 | -------------------------------------------------------------------------------- /pkg/common/storage/model/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model // import "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model/relation" 16 | -------------------------------------------------------------------------------- /pkg/common/storage/model/friend.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "go.mongodb.org/mongo-driver/bson/primitive" 19 | "time" 20 | ) 21 | 22 | // Friend represents the data structure for a friend relationship in MongoDB. 23 | type Friend struct { 24 | ID primitive.ObjectID `bson:"_id"` 25 | OwnerUserID string `bson:"owner_user_id"` 26 | FriendUserID string `bson:"friend_user_id"` 27 | Remark string `bson:"remark"` 28 | CreateTime time.Time `bson:"create_time"` 29 | AddSource int32 `bson:"add_source"` 30 | OperatorUserID string `bson:"operator_user_id"` 31 | Ex string `bson:"ex"` 32 | IsPinned bool `bson:"is_pinned"` 33 | } 34 | -------------------------------------------------------------------------------- /pkg/common/storage/model/friend_request.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type FriendRequest struct { 22 | FromUserID string `bson:"from_user_id"` 23 | ToUserID string `bson:"to_user_id"` 24 | HandleResult int32 `bson:"handle_result"` 25 | ReqMsg string `bson:"req_msg"` 26 | CreateTime time.Time `bson:"create_time"` 27 | HandlerUserID string `bson:"handler_user_id"` 28 | HandleMsg string `bson:"handle_msg"` 29 | HandleTime time.Time `bson:"handle_time"` 30 | Ex string `bson:"ex"` 31 | } 32 | -------------------------------------------------------------------------------- /pkg/common/storage/model/group_member.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type GroupMember struct { 22 | GroupID string `bson:"group_id"` 23 | UserID string `bson:"user_id"` 24 | Nickname string `bson:"nickname"` 25 | FaceURL string `bson:"face_url"` 26 | RoleLevel int32 `bson:"role_level"` 27 | JoinTime time.Time `bson:"join_time"` 28 | JoinSource int32 `bson:"join_source"` 29 | InviterUserID string `bson:"inviter_user_id"` 30 | OperatorUserID string `bson:"operator_user_id"` 31 | MuteEndTime time.Time `bson:"mute_end_time"` 32 | Ex string `bson:"ex"` 33 | } 34 | -------------------------------------------------------------------------------- /pkg/common/storage/model/group_request.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type GroupRequest struct { 22 | UserID string `bson:"user_id"` 23 | GroupID string `bson:"group_id"` 24 | HandleResult int32 `bson:"handle_result"` 25 | ReqMsg string `bson:"req_msg"` 26 | HandledMsg string `bson:"handled_msg"` 27 | ReqTime time.Time `bson:"req_time"` 28 | HandleUserID string `bson:"handle_user_id"` 29 | HandledTime time.Time `bson:"handled_time"` 30 | JoinSource int32 `bson:"join_source"` 31 | InviterUserID string `bson:"inviter_user_id"` 32 | Ex string `bson:"ex"` 33 | } 34 | -------------------------------------------------------------------------------- /pkg/common/storage/model/log.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type Log struct { 22 | LogID string `bson:"log_id"` 23 | Platform string `bson:"platform"` 24 | UserID string `bson:"user_id"` 25 | CreateTime time.Time `bson:"create_time"` 26 | Url string `bson:"url"` 27 | FileName string `bson:"file_name"` 28 | SystemType string `bson:"system_type"` 29 | AppFramework string `bson:"app_framework"` 30 | Version string `bson:"version"` 31 | Ex string `bson:"ex"` 32 | } 33 | -------------------------------------------------------------------------------- /pkg/common/storage/model/object.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type Object struct { 22 | Name string `bson:"name"` 23 | UserID string `bson:"user_id"` 24 | Hash string `bson:"hash"` 25 | Engine string `bson:"engine"` 26 | Key string `bson:"key"` 27 | Size int64 `bson:"size"` 28 | ContentType string `bson:"content_type"` 29 | Group string `bson:"group"` 30 | CreateTime time.Time `bson:"create_time"` 31 | } 32 | -------------------------------------------------------------------------------- /pkg/common/storage/model/seq.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type SeqConversation struct { 4 | ConversationID string `bson:"conversation_id"` 5 | MaxSeq int64 `bson:"max_seq"` 6 | MinSeq int64 `bson:"min_seq"` 7 | } 8 | -------------------------------------------------------------------------------- /pkg/common/storage/model/seq_user.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type SeqUser struct { 4 | UserID string `bson:"user_id"` 5 | ConversationID string `bson:"conversation_id"` 6 | MinSeq int64 `bson:"min_seq"` 7 | MaxSeq int64 `bson:"max_seq"` 8 | ReadSeq int64 `bson:"read_seq"` 9 | } 10 | -------------------------------------------------------------------------------- /pkg/common/storage/model/subscribe.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | // SubscribeUserTableName collection constant. 18 | const ( 19 | SubscribeUserTableName = "subscribe_user" 20 | ) 21 | 22 | // SubscribeUser collection structure. 23 | type SubscribeUser struct { 24 | UserID string `bson:"user_id" json:"userID"` 25 | UserIDList []string `bson:"user_id_list" json:"userIDList"` 26 | } 27 | 28 | func (SubscribeUser) TableName() string { 29 | return SubscribeUserTableName 30 | } 31 | -------------------------------------------------------------------------------- /pkg/common/storage/model/user.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type User struct { 22 | UserID string `bson:"user_id"` 23 | Nickname string `bson:"nickname"` 24 | FaceURL string `bson:"face_url"` 25 | Ex string `bson:"ex"` 26 | AppMangerLevel int32 `bson:"app_manger_level"` 27 | GlobalRecvMsgOpt int32 `bson:"global_recv_msg_opt"` 28 | CreateTime time.Time `bson:"create_time"` 29 | } 30 | 31 | func (u *User) GetNickname() string { 32 | return u.Nickname 33 | } 34 | 35 | func (u *User) GetFaceURL() string { 36 | return u.FaceURL 37 | } 38 | 39 | func (u *User) GetUserID() string { 40 | return u.UserID 41 | } 42 | 43 | func (u *User) GetEx() string { 44 | return u.Ex 45 | } 46 | -------------------------------------------------------------------------------- /pkg/common/storage/versionctx/rpc.go: -------------------------------------------------------------------------------- 1 | package versionctx 2 | 3 | import ( 4 | "context" 5 | "google.golang.org/grpc" 6 | ) 7 | 8 | func EnableVersionCtx() grpc.ServerOption { 9 | return grpc.ChainUnaryInterceptor(enableVersionCtxInterceptor) 10 | } 11 | 12 | func enableVersionCtxInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { 13 | return handler(WithVersionLog(ctx), req) 14 | } 15 | -------------------------------------------------------------------------------- /pkg/common/storage/versionctx/version.go: -------------------------------------------------------------------------------- 1 | package versionctx 2 | 3 | import ( 4 | "context" 5 | tablerelation "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" 6 | "sync" 7 | ) 8 | 9 | type Collection struct { 10 | Name string 11 | Doc *tablerelation.VersionLog 12 | } 13 | 14 | type versionKey struct{} 15 | 16 | func WithVersionLog(ctx context.Context) context.Context { 17 | return context.WithValue(ctx, versionKey{}, &VersionLog{}) 18 | } 19 | 20 | func GetVersionLog(ctx context.Context) *VersionLog { 21 | if v, ok := ctx.Value(versionKey{}).(*VersionLog); ok { 22 | return v 23 | } 24 | return nil 25 | } 26 | 27 | type VersionLog struct { 28 | lock sync.Mutex 29 | data []Collection 30 | } 31 | 32 | func (v *VersionLog) Append(data ...Collection) { 33 | if v == nil || len(data) == 0 { 34 | return 35 | } 36 | v.lock.Lock() 37 | defer v.lock.Unlock() 38 | v.data = append(v.data, data...) 39 | } 40 | 41 | func (v *VersionLog) Get() []Collection { 42 | if v == nil { 43 | return nil 44 | } 45 | v.lock.Lock() 46 | defer v.lock.Unlock() 47 | return v.data 48 | } 49 | -------------------------------------------------------------------------------- /pkg/common/webhook/condition.go: -------------------------------------------------------------------------------- 1 | package webhook 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/open-im-server/v3/pkg/common/config" 6 | ) 7 | 8 | func WithCondition(ctx context.Context, before *config.BeforeConfig, callback func(context.Context) error) error { 9 | if !before.Enable { 10 | return nil 11 | } 12 | return callback(ctx) 13 | } 14 | -------------------------------------------------------------------------------- /pkg/common/webhook/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package webhook // import "github.com/openimsdk/open-im-server/v3/pkg/common/webhook" 16 | -------------------------------------------------------------------------------- /pkg/common/webhook/http_client_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package webhook 16 | -------------------------------------------------------------------------------- /pkg/dbbuild/builder.go: -------------------------------------------------------------------------------- 1 | package dbbuild 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/openimsdk/open-im-server/v3/pkg/common/config" 7 | "github.com/openimsdk/tools/db/mongoutil" 8 | "github.com/redis/go-redis/v9" 9 | ) 10 | 11 | type Builder interface { 12 | Mongo(ctx context.Context) (*mongoutil.Client, error) 13 | Redis(ctx context.Context) (redis.UniversalClient, error) 14 | } 15 | 16 | func NewBuilder(mongoConf *config.Mongo, redisConf *config.Redis) Builder { 17 | if config.Standalone() { 18 | globalStandalone.setConfig(mongoConf, redisConf) 19 | return globalStandalone 20 | } 21 | return µservices{ 22 | mongo: mongoConf, 23 | redis: redisConf, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pkg/dbbuild/microservices.go: -------------------------------------------------------------------------------- 1 | package dbbuild 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/openimsdk/open-im-server/v3/pkg/common/config" 7 | "github.com/openimsdk/tools/db/mongoutil" 8 | "github.com/openimsdk/tools/db/redisutil" 9 | "github.com/redis/go-redis/v9" 10 | ) 11 | 12 | type microservices struct { 13 | mongo *config.Mongo 14 | redis *config.Redis 15 | } 16 | 17 | func (x *microservices) Mongo(ctx context.Context) (*mongoutil.Client, error) { 18 | return mongoutil.NewMongoDB(ctx, x.mongo.Build()) 19 | } 20 | 21 | func (x *microservices) Redis(ctx context.Context) (redis.UniversalClient, error) { 22 | if x.redis.Disable { 23 | return nil, nil 24 | } 25 | return redisutil.NewRedisClient(ctx, x.redis.Build()) 26 | } 27 | -------------------------------------------------------------------------------- /pkg/localcache/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package localcache // import "github.com/openimsdk/open-im-server/v3/pkg/localcache" 16 | -------------------------------------------------------------------------------- /pkg/localcache/link/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package link // import "github.com/openimsdk/open-im-server/v3/pkg/localcache/link" 16 | -------------------------------------------------------------------------------- /pkg/localcache/link/link_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package link 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | func TestName(t *testing.T) { 22 | 23 | v := New(1) 24 | 25 | //v.Link("a:1", "b:1", "c:1", "d:1") 26 | v.Link("a:1", "b:1", "c:1") 27 | v.Link("z:1", "b:1") 28 | 29 | //v.DelKey("a:1") 30 | v.Del("z:1") 31 | 32 | t.Log(v) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /pkg/localcache/lru/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package lru // import "github.com/openimsdk/open-im-server/v3/pkg/localcache/lru" 16 | -------------------------------------------------------------------------------- /pkg/localcache/lru/lru.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package lru 16 | 17 | import "github.com/hashicorp/golang-lru/v2/simplelru" 18 | 19 | type EvictCallback[K comparable, V any] simplelru.EvictCallback[K, V] 20 | 21 | type LRU[K comparable, V any] interface { 22 | Get(key K, fetch func() (V, error)) (V, error) 23 | Set(key K, value V) 24 | SetHas(key K, value V) bool 25 | GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) 26 | Del(key K) bool 27 | Stop() 28 | } 29 | 30 | type Target interface { 31 | IncrGetHit() 32 | IncrGetSuccess() 33 | IncrGetFailed() 34 | 35 | IncrDelHit() 36 | IncrDelNotFound() 37 | } 38 | -------------------------------------------------------------------------------- /pkg/localcache/tool.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package localcache 16 | 17 | func AnyValue[V any](v any, err error) (V, error) { 18 | if err != nil { 19 | var zero V 20 | return zero, err 21 | } 22 | return v.(V), nil 23 | } 24 | -------------------------------------------------------------------------------- /pkg/msgprocessor/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package msgprocessor // import "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" 16 | -------------------------------------------------------------------------------- /pkg/notification/common_user/common.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package common_user 16 | 17 | type CommonUser interface { 18 | GetNickname() string 19 | GetFaceURL() string 20 | GetUserID() string 21 | GetEx() string 22 | } 23 | 24 | type CommonGroup interface { 25 | GetNickname() string 26 | GetFaceURL() string 27 | GetGroupID() string 28 | GetEx() string 29 | } 30 | -------------------------------------------------------------------------------- /pkg/rpccache/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rpccache // import "github.com/openimsdk/open-im-server/v3/pkg/rpccache" 16 | -------------------------------------------------------------------------------- /pkg/rpcli/auth.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/protocol/auth" 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | func NewAuthClient(cc grpc.ClientConnInterface) *AuthClient { 10 | return &AuthClient{auth.NewAuthClient(cc)} 11 | } 12 | 13 | type AuthClient struct { 14 | auth.AuthClient 15 | } 16 | 17 | func (x *AuthClient) KickTokens(ctx context.Context, tokens []string) error { 18 | if len(tokens) == 0 { 19 | return nil 20 | } 21 | return ignoreResp(x.AuthClient.KickTokens(ctx, &auth.KickTokensReq{Tokens: tokens})) 22 | } 23 | 24 | func (x *AuthClient) InvalidateToken(ctx context.Context, req *auth.InvalidateTokenReq) error { 25 | return ignoreResp(x.AuthClient.InvalidateToken(ctx, req)) 26 | } 27 | 28 | func (x *AuthClient) ParseToken(ctx context.Context, token string) (*auth.ParseTokenResp, error) { 29 | return x.AuthClient.ParseToken(ctx, &auth.ParseTokenReq{Token: token}) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/rpcli/msggateway.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "github.com/openimsdk/protocol/msggateway" 5 | "google.golang.org/grpc" 6 | ) 7 | 8 | func NewMsgGatewayClient(cc grpc.ClientConnInterface) *MsgGatewayClient { 9 | return &MsgGatewayClient{msggateway.NewMsgGatewayClient(cc)} 10 | } 11 | 12 | type MsgGatewayClient struct { 13 | msggateway.MsgGatewayClient 14 | } 15 | -------------------------------------------------------------------------------- /pkg/rpcli/push.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "github.com/openimsdk/protocol/push" 5 | "google.golang.org/grpc" 6 | ) 7 | 8 | func NewPushMsgServiceClient(cc grpc.ClientConnInterface) *PushMsgServiceClient { 9 | return &PushMsgServiceClient{push.NewPushMsgServiceClient(cc)} 10 | } 11 | 12 | type PushMsgServiceClient struct { 13 | push.PushMsgServiceClient 14 | } 15 | -------------------------------------------------------------------------------- /pkg/rpcli/relation.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/protocol/relation" 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | func NewRelationClient(cc grpc.ClientConnInterface) *RelationClient { 10 | return &RelationClient{relation.NewFriendClient(cc)} 11 | } 12 | 13 | type RelationClient struct { 14 | relation.FriendClient 15 | } 16 | 17 | func (x *RelationClient) GetFriendsInfo(ctx context.Context, ownerUserID string, friendUserIDs []string) ([]*relation.FriendInfoOnly, error) { 18 | if len(friendUserIDs) == 0 { 19 | return nil, nil 20 | } 21 | req := &relation.GetFriendInfoReq{OwnerUserID: ownerUserID, FriendUserIDs: friendUserIDs} 22 | return extractField(ctx, x.FriendClient.GetFriendInfo, req, (*relation.GetFriendInfoResp).GetFriendInfos) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/rpcli/rtc.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "github.com/openimsdk/protocol/rtc" 5 | "google.golang.org/grpc" 6 | ) 7 | 8 | func NewRtcServiceClient(cc grpc.ClientConnInterface) *RtcServiceClient { 9 | return &RtcServiceClient{rtc.NewRtcServiceClient(cc)} 10 | } 11 | 12 | type RtcServiceClient struct { 13 | rtc.RtcServiceClient 14 | } 15 | -------------------------------------------------------------------------------- /pkg/rpcli/third.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "github.com/openimsdk/protocol/third" 5 | "google.golang.org/grpc" 6 | ) 7 | 8 | func NewThirdClient(cc grpc.ClientConnInterface) *ThirdClient { 9 | return &ThirdClient{third.NewThirdClient(cc)} 10 | } 11 | 12 | type ThirdClient struct { 13 | third.ThirdClient 14 | } 15 | -------------------------------------------------------------------------------- /pkg/rpcli/tool.go: -------------------------------------------------------------------------------- 1 | package rpcli 2 | 3 | import ( 4 | "context" 5 | "github.com/openimsdk/tools/errs" 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | func extractField[A, B, C any](ctx context.Context, fn func(ctx context.Context, req *A, opts ...grpc.CallOption) (*B, error), req *A, get func(*B) C) (C, error) { 10 | resp, err := fn(ctx, req) 11 | if err != nil { 12 | var c C 13 | return c, err 14 | } 15 | return get(resp), nil 16 | } 17 | 18 | func firstValue[A any](val []A, err error) (A, error) { 19 | if err != nil { 20 | var a A 21 | return a, err 22 | } 23 | if len(val) == 0 { 24 | var a A 25 | return a, errs.ErrRecordNotFound.WrapMsg("record not found") 26 | } 27 | return val[0], nil 28 | } 29 | 30 | func ignoreResp(_ any, err error) error { 31 | return err 32 | } 33 | -------------------------------------------------------------------------------- /pkg/statistics/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package statistics // import "github.com/openimsdk/open-im-server/v3/pkg/statistics" 16 | -------------------------------------------------------------------------------- /pkg/util/conversationutil/conversationutil.go: -------------------------------------------------------------------------------- 1 | package conversationutil 2 | 3 | import ( 4 | "sort" 5 | "strings" 6 | ) 7 | 8 | func GenConversationIDForSingle(sendID, recvID string) string { 9 | l := []string{sendID, recvID} 10 | sort.Strings(l) 11 | return "si_" + strings.Join(l, "_") 12 | } 13 | 14 | func GenConversationUniqueKeyForGroup(groupID string) string { 15 | return groupID 16 | } 17 | 18 | func GenGroupConversationID(groupID string) string { 19 | return "sg_" + groupID 20 | } 21 | 22 | func IsGroupConversationID(conversationID string) bool { 23 | return strings.HasPrefix(conversationID, "sg_") 24 | } 25 | 26 | func IsNotificationConversationID(conversationID string) bool { 27 | return strings.HasPrefix(conversationID, "n_") 28 | } 29 | 30 | func GenConversationUniqueKeyForSingle(sendID, recvID string) string { 31 | l := []string{sendID, recvID} 32 | sort.Strings(l) 33 | return strings.Join(l, "_") 34 | } 35 | 36 | func GetNotificationConversationIDByConversationID(conversationID string) string { 37 | l := strings.Split(conversationID, "_") 38 | if len(l) > 1 { 39 | l[0] = "n" 40 | return strings.Join(l, "_") 41 | } 42 | return "" 43 | } 44 | 45 | func GetSelfNotificationConversationID(userID string) string { 46 | return "n_" + userID + "_" + userID 47 | } 48 | 49 | func GetSeqsBeginEnd(seqs []int64) (int64, int64) { 50 | if len(seqs) == 0 { 51 | return 0, 0 52 | } 53 | return seqs[0], seqs[len(seqs)-1] 54 | } 55 | -------------------------------------------------------------------------------- /pkg/util/conversationutil/doc.go: -------------------------------------------------------------------------------- 1 | package conversationutil // import "github.com/openimsdk/open-im-server/v3/pkg/util/conversationutil" 2 | -------------------------------------------------------------------------------- /pkg/util/hashutil/id.go: -------------------------------------------------------------------------------- 1 | package hashutil 2 | 3 | import ( 4 | "crypto/md5" 5 | "encoding/binary" 6 | "encoding/json" 7 | ) 8 | 9 | func IdHash(ids []string) uint64 { 10 | if len(ids) == 0 { 11 | return 0 12 | } 13 | data, _ := json.Marshal(ids) 14 | sum := md5.Sum(data) 15 | return binary.BigEndian.Uint64(sum[:]) 16 | } 17 | -------------------------------------------------------------------------------- /pkg/util/useronline/split.go: -------------------------------------------------------------------------------- 1 | package useronline 2 | 3 | import ( 4 | "errors" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | func ParseUserOnlineStatus(payload string) (string, []int32, error) { 10 | arr := strings.Split(payload, ":") 11 | if len(arr) == 0 { 12 | return "", nil, errors.New("invalid data") 13 | } 14 | userID := arr[len(arr)-1] 15 | if userID == "" { 16 | return "", nil, errors.New("userID is empty") 17 | } 18 | platformIDs := make([]int32, len(arr)-1) 19 | for i := range platformIDs { 20 | platformID, err := strconv.Atoi(arr[i]) 21 | if err != nil { 22 | return "", nil, err 23 | } 24 | platformIDs[i] = int32(platformID) 25 | } 26 | return userID, platformIDs, nil 27 | } 28 | -------------------------------------------------------------------------------- /scripts/template/LICENSE_TEMPLATES: -------------------------------------------------------------------------------- 1 | Copyright © {{.Year}} {{.Holder}} All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /scripts/template/boilerplate.txt: -------------------------------------------------------------------------------- 1 | Copyright © {{.Year}} {{.Holder}} All rights reserved. 2 | Use of this source code is governed by a MIT style 3 | license that can be found in the LICENSE file. 4 | -------------------------------------------------------------------------------- /scripts/template/project_README.md: -------------------------------------------------------------------------------- 1 | # Project myproject 2 | 3 | 4 | 5 | ## Features 6 | 7 | 8 | 9 | ## Getting Started 10 | 11 | ### Prerequisites 12 | 13 | 14 | 15 | ### Building 16 | 17 | 18 | 19 | ### Running 20 | 21 | 22 | 23 | ## Using 24 | 25 | 26 | 27 | ## Contributing 28 | 29 | 30 | 31 | ## Community(optional) 32 | 33 | 34 | 35 | ## Authors 36 | 37 | 38 | 39 | ## License 40 | 41 | 42 | -------------------------------------------------------------------------------- /start-config.yml: -------------------------------------------------------------------------------- 1 | serviceBinaries: 2 | openim-api: 1 3 | openim-crontask: 4 4 | openim-rpc-user: 1 5 | openim-msggateway: 1 6 | openim-push: 8 7 | openim-msgtransfer: 8 8 | openim-rpc-conversation: 1 9 | openim-rpc-auth: 1 10 | openim-rpc-group: 1 11 | openim-rpc-friend: 1 12 | openim-rpc-msg: 1 13 | openim-rpc-third: 1 14 | toolBinaries: 15 | - check-free-memory 16 | - check-component 17 | - seq 18 | maxFileDescriptors: 10000 19 | -------------------------------------------------------------------------------- /test/e2e/conformance/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/e2e_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package e2e 16 | 17 | import ( 18 | "flag" 19 | "testing" 20 | 21 | "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" 22 | ) 23 | 24 | // handleFlags sets up all flags and parses the command line. 25 | func handleFlags() { 26 | config.CopyFlags(config.Flags, flag.CommandLine) 27 | flag.Parse() 28 | } 29 | 30 | func TestMain(m *testing.M) { 31 | handleFlags() 32 | m.Run() 33 | } 34 | 35 | func TestE2E(t *testing.T) { 36 | RunE2ETests(t) 37 | } 38 | -------------------------------------------------------------------------------- /test/e2e/framework/ginkgowrapper/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/framework/ginkgowrapper/ginkgowrapper.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ginkgowrapper 16 | -------------------------------------------------------------------------------- /test/e2e/framework/ginkgowrapper/ginkgowrapper_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ginkgowrapper 16 | -------------------------------------------------------------------------------- /test/e2e/framework/helpers/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/page/chat_page.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package page 16 | -------------------------------------------------------------------------------- /test/e2e/page/login_page.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package page 16 | -------------------------------------------------------------------------------- /test/e2e/performance/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/rpc/auth/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/rpc/conversation/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/rpc/friend/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/rpc/group/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/rpc/message/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/scalability/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/upgrade/.keep: -------------------------------------------------------------------------------- 1 | .keep -------------------------------------------------------------------------------- /test/e2e/web/Readme.md: -------------------------------------------------------------------------------- 1 | # OpenIM Web E2E 2 | 3 | -------------------------------------------------------------------------------- /test/readme: -------------------------------------------------------------------------------- 1 | ## Run the Tests 2 | 3 | read: [Test Docs](./docs/contrib/test.md) 4 | 5 | To run a single test or set of tests, you'll need the [Ginkgo](https://github.com/onsi/ginkgo) tool installed on your 6 | machine: 7 | 8 | ```console 9 | go install github.com/onsi/ginkgo/ginkgo@latest 10 | ``` 11 | 12 | ```shell 13 | ginkgo --help 14 | --focus value 15 | If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed. 16 | 17 | ``` 18 | -------------------------------------------------------------------------------- /test/stress-test-v2/README.md: -------------------------------------------------------------------------------- 1 | # Stress Test V2 2 | 3 | ## Usage 4 | 5 | You need set `TestTargetUserList` variables. 6 | 7 | ### Build 8 | 9 | ```bash 10 | 11 | go build -o test/stress-test-v2/stress-test-v2 test/stress-test-v2/main.go 12 | ``` 13 | 14 | ### Excute 15 | 16 | ```bash 17 | 18 | tools/stress-test-v2/stress-test-v2 -c config/ 19 | ``` 20 | -------------------------------------------------------------------------------- /test/stress-test/README.md: -------------------------------------------------------------------------------- 1 | # Stress Test 2 | 3 | ## Usage 4 | 5 | You need set `TestTargetUserList` and `DefaultGroupID` variables. 6 | 7 | ### Build 8 | 9 | ```bash 10 | 11 | go build -o test/stress-test/stress-test test/stress-test/main.go 12 | ``` 13 | 14 | ### Excute 15 | 16 | ```bash 17 | 18 | tools/stress-test/stress-test -c config/ 19 | ``` 20 | -------------------------------------------------------------------------------- /test/testdata/db/messages.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/db/messages.json -------------------------------------------------------------------------------- /test/testdata/db/users.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/db/users.json -------------------------------------------------------------------------------- /test/testdata/requests/login.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/requests/login.json -------------------------------------------------------------------------------- /test/testdata/requests/register.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/requests/register.json -------------------------------------------------------------------------------- /test/testdata/requests/send-message.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/requests/send-message.json -------------------------------------------------------------------------------- /test/testdata/responses/login.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/responses/login.json -------------------------------------------------------------------------------- /test/testdata/responses/register.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/responses/register.json -------------------------------------------------------------------------------- /test/testdata/responses/sendMessage.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-server/75367545ea330bdb67a6e4242cb31e5652ce44dc/test/testdata/responses/sendMessage.json -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # Notes about go workspace 2 | 3 | As openim is using go1.18's [workspace feature](https://go.dev/doc/tutorial/workspaces), once you add a new module, you need to run `go work use -r .` at root directory to update the workspace synced. 4 | 5 | ### Create a new extensions 6 | 7 | 1. Create your tools_name directory in pkg `/tools` first and cd into it. 8 | 2. Init the project. 9 | 3. Then `go work use -r .` at current directory to update the workspace. 10 | 4. Create your tools 11 | 12 | You can execute the following commands to do things above: 13 | 14 | ```bash 15 | # edit the CRD_NAME and CRD_GROUP to your own 16 | export OPENIM_TOOLS_NAME= 17 | 18 | # copy and paste to create a new CRD and Controller 19 | mkdir tools/${OPENIM_TOOLS_NAME} 20 | cd tools/${OPENIM_TOOLS_NAME} 21 | go mod init github.com/openimsdk/open-im-server/tools/${OPENIM_TOOLS_NAME} 22 | go mod tidy 23 | go work use -r . 24 | cd ../.. 25 | ``` -------------------------------------------------------------------------------- /tools/check-free-memory/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/shirou/gopsutil/mem" 8 | ) 9 | 10 | func main() { 11 | vMem, err := mem.VirtualMemory() 12 | if err != nil { 13 | fmt.Fprintf(os.Stderr, "Failed to get virtual memory info: %v\n", err) 14 | os.Exit(1) 15 | } 16 | 17 | // Use the Available field to get the available memory 18 | availableMemoryGB := float64(vMem.Available) / float64(1024*1024*1024) 19 | 20 | if availableMemoryGB < 1.0 { 21 | fmt.Fprintf(os.Stderr, "System available memory is less than 1GB: %.2fGB\n", availableMemoryGB) 22 | os.Exit(1) 23 | } else { 24 | fmt.Printf("System available memory is sufficient: %.2fGB\n", availableMemoryGB) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/imctl/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "fmt" 18 | 19 | func main() { 20 | 21 | fmt.Println("imctl") 22 | } 23 | -------------------------------------------------------------------------------- /tools/ncpu/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2024 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "runtime" 20 | 21 | "go.uber.org/automaxprocs/maxprocs" 22 | ) 23 | 24 | func main() { 25 | // Set maxprocs with a custom logger that does nothing to ignore logs. 26 | maxprocs.Set(maxprocs.Logger(func(string, ...interface{}) { 27 | // Intentionally left blank to suppress all log output from automaxprocs. 28 | })) 29 | 30 | // Now this will print the GOMAXPROCS value without printing the automaxprocs log message. 31 | fmt.Println(runtime.GOMAXPROCS(0)) 32 | } 33 | -------------------------------------------------------------------------------- /tools/ncpu/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "testing" 18 | 19 | func Test_main(t *testing.T) { 20 | tests := []struct { 21 | name string 22 | }{ 23 | { 24 | name: "Test_main", 25 | }, 26 | { 27 | name: "Test_main2", 28 | }, 29 | } 30 | for _, tt := range tests { 31 | t.Run(tt.name, func(t *testing.T) { 32 | main() 33 | }) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tools/s3/README.md: -------------------------------------------------------------------------------- 1 | # After s3 switches the storage engine, convert the data 2 | 3 | - build 4 | ```shell 5 | go build -o s3convert main.go 6 | ``` 7 | 8 | - start 9 | ```shell 10 | ./s3convert -config -name 11 | # ./s3convert -config ./../../config -name minio 12 | ``` 13 | -------------------------------------------------------------------------------- /tools/s3/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "github.com/openimsdk/open-im-server/v3/tools/s3/internal" 7 | "os" 8 | ) 9 | 10 | func main() { 11 | var ( 12 | name string 13 | config string 14 | ) 15 | flag.StringVar(&name, "name", "", "old previous storage name") 16 | flag.StringVar(&config, "config", "", "config directory") 17 | flag.Parse() 18 | if err := internal.Main(config, name); err != nil { 19 | fmt.Fprintln(os.Stderr, err) 20 | os.Exit(1) 21 | } 22 | fmt.Fprintln(os.Stdout, "success") 23 | } 24 | -------------------------------------------------------------------------------- /tools/seq/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/openimsdk/open-im-server/v3/tools/seq/internal" 10 | ) 11 | 12 | func main() { 13 | var ( 14 | config string 15 | second int 16 | ) 17 | flag.StringVar(&config, "c", "", "config directory") 18 | flag.IntVar(&second, "sec", 3600*24, "delayed deletion of the original seq key after conversion") 19 | flag.Parse() 20 | if err := internal.Main(config, time.Duration(second)*time.Second); err != nil { 21 | fmt.Println("seq task", err) 22 | os.Exit(1) 23 | return 24 | } 25 | fmt.Println("seq task success!") 26 | } 27 | -------------------------------------------------------------------------------- /tools/url2im/pkg/config.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pkg 16 | 17 | import "time" 18 | 19 | type Config struct { 20 | TaskPath string 21 | ProgressPath string 22 | Concurrency int 23 | Retry int 24 | Timeout time.Duration 25 | Api string 26 | UserID string 27 | Secret string 28 | TempDir string 29 | CacheSize int64 30 | } 31 | -------------------------------------------------------------------------------- /tools/url2im/pkg/http.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pkg 16 | 17 | import "net/http" 18 | 19 | func DefaultRequestHeader(header http.Header) { 20 | header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36") 21 | } 22 | -------------------------------------------------------------------------------- /tools/url2im/pkg/md5.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2023 OpenIM. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package pkg 16 | 17 | import ( 18 | "crypto/md5" 19 | "encoding/hex" 20 | "hash" 21 | "io" 22 | ) 23 | 24 | func NewMd5Reader(r io.Reader) *Md5Reader { 25 | return &Md5Reader{h: md5.New(), r: r} 26 | } 27 | 28 | type Md5Reader struct { 29 | h hash.Hash 30 | r io.Reader 31 | } 32 | 33 | func (r *Md5Reader) Read(p []byte) (n int, err error) { 34 | n, err = r.r.Read(p) 35 | if err == nil && n > 0 { 36 | r.h.Write(p[:n]) 37 | } 38 | return 39 | } 40 | 41 | func (r *Md5Reader) Md5() string { 42 | return hex.EncodeToString(r.h.Sum(nil)) 43 | } 44 | -------------------------------------------------------------------------------- /version/version: -------------------------------------------------------------------------------- 1 | main -------------------------------------------------------------------------------- /version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | _ "embed" 5 | "strings" 6 | ) 7 | 8 | //go:embed version 9 | var Version string 10 | 11 | func init() { 12 | Version = strings.Trim(Version, "\n") 13 | Version = strings.TrimSpace(Version) 14 | } 15 | --------------------------------------------------------------------------------