Skip to content

Commit

Permalink
fix many bug
Browse files Browse the repository at this point in the history
  • Loading branch information
showurl committed Mar 5, 2023
1 parent c965990 commit 2d68a0b
Show file tree
Hide file tree
Showing 86 changed files with 6,414 additions and 4,771 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ xxim-server是一个功能超多的开箱即用的IM服务器。它的诞生是
[![Go Reference](https://pkg.go.dev/badge/github.com/cherish-chat/xxim-server.svg)](https://pkg.go.dev/github.com/cherish-chat/xxim-server)
[![Awesome Go](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/avelino/awesome-go)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![XXIM](https://api.cherish.chat/api/server/onlineshield/202301311756)](https://xxim.cherish.chat)
[![XXIM](https://api.cherish.chat/api/server/onlineshield/202303051934)](https://xxim.cherish.chat)

</div>

Expand All @@ -24,15 +24,18 @@ xxim-server是一个功能超多的开箱即用的IM服务器。它的诞生是

xxim-server代码不复杂,im大多逻辑都在于客户端,所以xxim-server只是一个简单的im服务器,但它具备了一个IM应有的全部功能。

在线体验:[https://xxim.cherish.chat](https://xxim.cherish.chat)

#### 包括但不限于:

* [x] 发送消息(可定时的、可群发),包括:文本、图片、语音、视频、文件、位置、名片、撤回、转发、@、表情、对方正在输入、自定义消息等
* [x] 按需拉取离线消息,且没有消息数量/天数限制
* [x] 当用户不在线时,通过厂商推送(极光、腾讯、Mob)将消息推送给用户
* [x] 群聊20万成员上限
* [x] 一条长连接通讯
* [x] 一条长连接通讯、无http
* [x] 🔐通讯层加密
* [x] golang client sdk,可接入[ChatGPT](https://github.com/cherish-chat/chatgpt.git)
* [x] golang client sdk,可接入[ChatGPT](https://github.com/cherish-chat/xxim-bot-chatgpt)
* [x] 开源后台管理系统,可自定义配置[xxim-mgmt-app](https://github.com/cherish-chat/xxim-mgmt-app.git)
* [ ] 音视频通话、IOS支持`Callkit`


Expand Down
2 changes: 2 additions & 0 deletions app/appmgmt/appmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"github.com/cherish-chat/xxim-server/app/appmgmt/internal/config"
"github.com/cherish-chat/xxim-server/app/appmgmt/internal/logic"
"github.com/cherish-chat/xxim-server/app/appmgmt/internal/server"
"github.com/cherish-chat/xxim-server/app/appmgmt/internal/svc"
"github.com/cherish-chat/xxim-server/app/mgmt/mgmtservice"
Expand Down Expand Up @@ -33,6 +34,7 @@ func main() {
}
})
defer s.Stop()
logic.NewStatsLogic(ctx).Start()

fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
Expand Down
33 changes: 33 additions & 0 deletions app/appmgmt/appmgmtmodel/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package appmgmtmodel

type Stats struct {
Date string `gorm:"column:date;type:varchar(10);index:date_type_idx,unique;not null" json:"date"`
Type string `gorm:"column:type;type:varchar(32);index:date_type_idx,unique;not null" json:"type"`
Val int `gorm:"column:val;type:bigint(20);not null" json:"val"`
}

func (m *Stats) TableName() string {
return APPMGR_TABLE_PREFIX + "stats"
}

const (
StatsTypeNewUser = "newUser"
StatsTypeNewGroup = "newGroup"
StatsTypeTodayMsg = "todayMsg"
StatsTypeTodayMsgUser = "todayMsgUser"
StatsTypeTodayAliveGroup = "todayAliveGroup"
StatsTypeTodayAliveSingle = "todayAliveSingle"
StatsTypeTodayAliveUser = "todayAliveUser"
StatsTypeTodayNewFriend = "todayNewFriend"
)

var StatsNameMap = map[string]string{
StatsTypeNewUser: "新增用户",
StatsTypeNewGroup: "新增群组",
StatsTypeTodayMsg: "今日消息",
StatsTypeTodayMsgUser: "发消息用户",
StatsTypeTodayAliveGroup: "活跃群组",
StatsTypeTodayAliveSingle: "活跃单聊",
StatsTypeTodayAliveUser: "活跃用户",
StatsTypeTodayNewFriend: "新增好友",
}
8 changes: 8 additions & 0 deletions app/appmgmt/appmgmtservice/appMgmtService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions app/appmgmt/internal/logic/getAllAppMgmtShieldWordLogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package logic
import (
"context"
"github.com/cherish-chat/xxim-server/app/appmgmt/appmgmtmodel"
"github.com/cherish-chat/xxim-server/common/utils"
"github.com/cherish-chat/xxim-server/common/xorm"

"github.com/cherish-chat/xxim-server/app/appmgmt/internal/svc"
Expand Down Expand Up @@ -32,6 +33,21 @@ func (l *GetAllAppMgmtShieldWordLogic) GetAllAppMgmtShieldWord(in *pb.GetAllAppM
var models []*appmgmtmodel.ShieldWord
wheres := xorm.NewGormWhere()
if in.Filter != nil {
for k, v := range in.Filter {
if v == "" {
continue
}
switch k {
case "word":
wheres = append(wheres, xorm.Where("word LIKE ?", v+"%"))
case "time_gte":
val := utils.AnyToInt64(v)
wheres = append(wheres, xorm.Where("createTime >= ?", val))
case "time_lte":
val := utils.AnyToInt64(v)
wheres = append(wheres, xorm.Where("createTime <= ?", val))
}
}
}
count, err := xorm.ListWithPagingOrder(l.svcCtx.Mysql(), &models, &appmgmtmodel.ShieldWord{}, in.Page.Page, in.Page.Size, "createTime DESC", wheres...)
if err != nil {
Expand Down
40 changes: 40 additions & 0 deletions app/appmgmt/internal/logic/getLatestVersionLogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package logic

import (
"context"
"github.com/cherish-chat/xxim-server/app/appmgmt/appmgmtmodel"

"github.com/cherish-chat/xxim-server/app/appmgmt/internal/svc"
"github.com/cherish-chat/xxim-server/common/pb"

"github.com/zeromicro/go-zero/core/logx"
)

type GetLatestVersionLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}

func NewGetLatestVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLatestVersionLogic {
return &GetLatestVersionLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}

func (l *GetLatestVersionLogic) GetLatestVersion(in *pb.GetLatestVersionReq) (*pb.GetLatestVersionResp, error) {
platform := in.CommonReq.Platform
dest := &appmgmtmodel.Version{}
err := l.svcCtx.Mysql().Model(dest).Where("platform = ?", platform).Order("createTime desc").First(dest).Error
if err != nil {
return &pb.GetLatestVersionResp{
AppMgmtVersion: &pb.AppMgmtVersion{
Version: in.CommonReq.AppVersion,
Platform: platform,
},
}, err
}
return &pb.GetLatestVersionResp{AppMgmtVersion: dest.ToPB()}, nil
}
Loading

0 comments on commit 2d68a0b

Please sign in to comment.