Skip to content

Commit

Permalink
feat: implement request max count limit. (#118)
Browse files Browse the repository at this point in the history
* feat: update max Seq format method.

* update Format method in pb.

* update to correct constant.

* update format method in pb.

* feat: update conversation fields.

* update pb files.

* update ConversationsDestructMsgs method.

* update conversation and msg destruct pb.

* feat: update GroupInfoForSetEX struct.

* update group pb.

* feat: implement request max count limit.
  • Loading branch information
mo3et authored Sep 4, 2024
1 parent 243ecff commit 7a5c306
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 50 deletions.
21 changes: 0 additions & 21 deletions .github/code-language-detector.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/code-language-detector.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/comment-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Non-English Comments Check

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
non-english-comments-check:
runs-on: ubuntu-latest

env:
# need ignore Dirs
EXCLUDE_DIRS: ".git docs tests scripts assets node_modules build"
# need ignore Files
EXCLUDE_FILES: "*.md *.txt *.html *.css *.min.js *.mdx"

steps:
- uses: actions/checkout@v4

- name: Search for Non-English comments
run: |
set -e
# Define the regex pattern to match Chinese characters
pattern='[\p{Han}]'
# Process the directories to be excluded
exclude_dirs=""
for dir in $EXCLUDE_DIRS; do
exclude_dirs="$exclude_dirs --exclude-dir=$dir"
done
# Process the file types to be excluded
exclude_files=""
for file in $EXCLUDE_FILES; do
exclude_files="$exclude_files --exclude=$file"
done
# Use grep to find all comments containing Non-English characters and save to file
grep -Pnr "$pattern" . $exclude_dirs $exclude_files > non_english_comments.txt || true
- name: Output non-English comments are found
run: |
if [ -s non_english_comments.txt ]; then
echo "Non-English comments found in the following locations:"
cat non_english_comments.txt
exit 1 # terminate the workflow
else
echo "No Non_English comments found."
fi
34 changes: 32 additions & 2 deletions group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func (x *CreateGroupReq) Check() error {
return errors.New("GroupType is invalid")
}
if x.OwnerUserID == "" {
return errors.New("ownerUserID")
return errors.New("ownerUserID is empty")
}
if len(x.MemberUserIDs) > 1000 {
return errors.New("too many MemberUserIDs, need to be less than 1000")
}
return nil
}
Expand Down Expand Up @@ -156,9 +159,14 @@ func (x *KickGroupMemberReq) Check() error {
if x.GroupID == "" {
return errors.New("groupID is empty")
}

if x.KickedUserIDs == nil {
return errors.New("kickUserIDs is empty")
}

if len(x.KickedUserIDs) > 1000 {
return errors.New("too many KickedUserIDs, need to be less than 1000")
}
return nil
}

Expand All @@ -179,9 +187,15 @@ func (x *InviteUserToGroupReq) Check() error {
if x.GroupID == "" {
return errors.New("groupID is empty")
}

if x.InvitedUserIDs == nil {
return errors.New("invitedUserIDs is empty")
}

if len(x.InvitedUserIDs) > 1000 {
return errors.New("too many InvitedUserIDs, need to be less than 1000")
}

return nil
}

Expand Down Expand Up @@ -284,7 +298,11 @@ func (x *SetGroupMemberInfo) Check() error {

func (x *SetGroupMemberInfoReq) Check() error {
if x.Members == nil {
return errors.New("Members is empty")
return errors.New("members is empty")
}

if len(x.Members) > 1000 {
return errors.New("too many Members, need to be less than 1000")
}
return nil
}
Expand All @@ -293,6 +311,10 @@ func (x *GetGroupAbstractInfoReq) Check() error {
if x.GroupIDs == nil {
return errors.New("GroupID is empty")
}

if len(x.GroupIDs) > 1000 {
return errors.New("too many GroupIDs, need to be less than 1000")
}
return nil
}

Expand All @@ -303,6 +325,10 @@ func (x *GetUserInGroupMembersReq) Check() error {
if x.UserID == "" {
return errors.New("userID is empty")
}

if len(x.GroupIDs) > 1000 {
return errors.New("too many GroupIDs, need to be less than 1000")
}
return nil
}

Expand Down Expand Up @@ -346,6 +372,10 @@ func (x *GetGroupUsersReqApplicationListReq) Check() error {
if x.UserIDs == nil {
return errors.New("UserID is empty")
}

if len(x.UserIDs) > 1000 {
return errors.New("too many UserIDs, need to be less than 1000")
}
return nil
}
func (x *GroupCreateCountReq) Check() error {
Expand Down
16 changes: 16 additions & 0 deletions relation/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (x *ImportFriendReq) Check() error {
if x.FriendUserIDs == nil {
return errors.New("friendUserIDS is empty")
}

if len(x.FriendUserIDs) > 1000 {
return errors.New("too many FriendUserIDs, need to be less than 1000")
}
return nil
}

Expand All @@ -72,6 +76,10 @@ func (x *GetDesignatedFriendsReq) Check() error {
if x.FriendUserIDs == nil {
return errors.New("friendUserIDS is empty")
}

// if len(x.FriendUserIDs) > 1000 {
// return errors.New("too many FriendUserIDs, need to be less than 1000")
// }
return nil
}

Expand Down Expand Up @@ -193,6 +201,10 @@ func (x *UpdateFriendsReq) Check() error {
if x.FriendUserIDs == nil {
return errors.New("friendUserIDs is empty")
}

if len(x.FriendUserIDs) > 1000 {
return errors.New("too many FriendUserIDs, need to be less than 1000")
}
return nil
}
func (x *GetSpecifiedFriendsInfoReq) Check() error {
Expand All @@ -202,6 +214,10 @@ func (x *GetSpecifiedFriendsInfoReq) Check() error {
if x.UserIDList == nil {
return errors.New("userIDList is empty")
}

if len(x.UserIDList) > 1000 {
return errors.New("too many UserIDs, need to be less than 1000")
}
return nil
}
func (x *GetFullFriendUserIDsReq) Check() error {
Expand Down

0 comments on commit 7a5c306

Please sign in to comment.