From 78b0181238b4b6d4d8b5c8d6b30de728b76c84d9 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Thu, 25 Jan 2024 17:10:55 +0800 Subject: [PATCH] feat: add copyright make lint and format --- internal/api/user.go | 10 +++++----- internal/push/push_to_client.go | 2 +- internal/rpc/user/user.go | 6 +++--- pkg/common/db/controller/user.go | 13 ++++++++++--- pkg/common/db/mgo/user.go | 10 +++++++++- .../discoveryregister/kubernetes/kubernetes.go | 4 ++-- pkg/util/flag/flag.go | 14 ++++++++++++++ pkg/util/genutil/genutil.go | 14 ++++++++++++++ pkg/util/genutil/genutil_test.go | 14 ++++++++++++++ tools/formitychecker/checker/checker.go | 14 ++++++++++++++ tools/formitychecker/config/config.go | 14 ++++++++++++++ tools/formitychecker/formitychecker.go | 14 ++++++++++++++ tools/imctl/imctl.go | 14 ++++++++++++++ 13 files changed, 128 insertions(+), 15 deletions(-) diff --git a/internal/api/user.go b/internal/api/user.go index 03d22c354..e7bbd4bfb 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -201,27 +201,27 @@ func (u *UserApi) GetSubscribeUsersStatus(c *gin.Context) { a2r.Call(user.UserClient.GetSubscribeUsersStatus, u.Client, c) } -// ProcessUserCommandAdd user general function add +// ProcessUserCommandAdd user general function add. func (u *UserApi) ProcessUserCommandAdd(c *gin.Context) { a2r.Call(user.UserClient.ProcessUserCommandAdd, u.Client, c) } -// ProcessUserCommandDelete user general function delete +// ProcessUserCommandDelete user general function delete. func (u *UserApi) ProcessUserCommandDelete(c *gin.Context) { a2r.Call(user.UserClient.ProcessUserCommandDelete, u.Client, c) } -// ProcessUserCommandUpdate user general function update +// ProcessUserCommandUpdate user general function update. func (u *UserApi) ProcessUserCommandUpdate(c *gin.Context) { a2r.Call(user.UserClient.ProcessUserCommandUpdate, u.Client, c) } -// ProcessUserCommandGet user general function get +// ProcessUserCommandGet user general function get. func (u *UserApi) ProcessUserCommandGet(c *gin.Context) { a2r.Call(user.UserClient.ProcessUserCommandGet, u.Client, c) } -// ProcessUserCommandGet user general function get all +// ProcessUserCommandGet user general function get all. func (u *UserApi) ProcessUserCommandGetAll(c *gin.Context) { a2r.Call(user.UserClient.ProcessUserCommandGetAll, u.Client, c) } diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go index ca9004605..72deb720d 100644 --- a/internal/push/push_to_client.go +++ b/internal/push/push_to_client.go @@ -144,7 +144,7 @@ func (p *Pusher) UnmarshalNotificationElem(bytes []byte, t any) error { } /* -k8s deployment,offline push group messages function +k8s deployment,offline push group messages function. */ func (p *Pusher) k8sOfflinePush2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData, wsResults []*msggateway.SingleMsgToUserResults) error { diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index e09c3299a..50c97f41b 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -389,7 +389,7 @@ func (s *userServer) GetSubscribeUsersStatus(ctx context.Context, return &pbuser.GetSubscribeUsersStatusResp{StatusList: onlineStatusList}, nil } -// ProcessUserCommandAdd user general function add +// ProcessUserCommandAdd user general function add. func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.ProcessUserCommandAddReq) (*pbuser.ProcessUserCommandAddResp, error) { err := authverify.CheckAccessV3(ctx, req.UserID) if err != nil { @@ -420,7 +420,7 @@ func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.Proc return &pbuser.ProcessUserCommandAddResp{}, nil } -// ProcessUserCommandDelete user general function delete +// ProcessUserCommandDelete user general function delete. func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.ProcessUserCommandDeleteReq) (*pbuser.ProcessUserCommandDeleteResp, error) { err := authverify.CheckAccessV3(ctx, req.UserID) if err != nil { @@ -442,7 +442,7 @@ func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.P return &pbuser.ProcessUserCommandDeleteResp{}, nil } -// ProcessUserCommandUpdate user general function update +// ProcessUserCommandUpdate user general function update. func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.ProcessUserCommandUpdateReq) (*pbuser.ProcessUserCommandUpdateResp, error) { err := authverify.CheckAccessV3(ctx, req.UserID) if err != nil { diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go index 1a3651076..8ba1c01d3 100644 --- a/pkg/common/db/controller/user.go +++ b/pkg/common/db/controller/user.go @@ -142,12 +142,12 @@ func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*rel return u.cache.GetUsersInfo(ctx, userIDs) } -// Find userInfo By Nickname +// Find userInfo By Nickname. func (u *userDatabase) FindByNickname(ctx context.Context, nickname string) (users []*relation.UserModel, err error) { return u.userDB.TakeByNickname(ctx, nickname) } -// Find notificationAccouts +// Find notificationAccouts. func (u *userDatabase) FindNotification(ctx context.Context, level int64) (users []*relation.UserModel, err error) { return u.userDB.TakeNotification(ctx, level) } @@ -190,7 +190,14 @@ func (u *userDatabase) Page(ctx context.Context, pagination pagination.Paginatio func (u *userDatabase) PageFindUser(ctx context.Context, level1 int64, level2 int64, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) { return u.userDB.PageFindUser(ctx, level1, level2, pagination) } -func (u *userDatabase) PageFindUserWithKeyword(ctx context.Context, level1 int64, level2 int64, userID, nickName string, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) { + +func (u *userDatabase) PageFindUserWithKeyword( + ctx context.Context, + level1 int64, + level2 int64, + userID, nickName string, + pagination pagination.Pagination, +) (count int64, users []*relation.UserModel, err error) { return u.userDB.PageFindUserWithKeyword(ctx, level1, level2, userID, nickName, pagination) } diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index ccbddad14..34a25ed08 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -90,7 +90,15 @@ func (u *UserMgo) PageFindUser(ctx context.Context, level1 int64, level2 int64, return mgoutil.FindPage[*relation.UserModel](ctx, u.coll, query, pagination) } -func (u *UserMgo) PageFindUserWithKeyword(ctx context.Context, level1 int64, level2 int64, userID string, nickName string, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) { + +func (u *UserMgo) PageFindUserWithKeyword( + ctx context.Context, + level1 int64, + level2 int64, + userID string, + nickName string, + pagination pagination.Pagination, +) (count int64, users []*relation.UserModel, err error) { // Initialize the base query with level conditions query := bson.M{ "$and": []bson.M{ diff --git a/pkg/common/discoveryregister/kubernetes/kubernetes.go b/pkg/common/discoveryregister/kubernetes/kubernetes.go index 06c58d961..f27ebc805 100644 --- a/pkg/common/discoveryregister/kubernetes/kubernetes.go +++ b/pkg/common/discoveryregister/kubernetes/kubernetes.go @@ -104,7 +104,7 @@ func getSelfHost(ctx context.Context) string { return host } -// like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88 +// like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88. func getMsgGatewayHost(ctx context.Context) []string { port := 88 instance := "openimserver" @@ -168,7 +168,7 @@ func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) { conn.Close() } -// do not use this method for call rpc +// do not use this method for call rpc. func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") return nil diff --git a/pkg/util/flag/flag.go b/pkg/util/flag/flag.go index 77c9246f5..0a8e527ab 100644 --- a/pkg/util/flag/flag.go +++ b/pkg/util/flag/flag.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package flag import ( diff --git a/pkg/util/genutil/genutil.go b/pkg/util/genutil/genutil.go index 36da89bbb..0948a7c49 100644 --- a/pkg/util/genutil/genutil.go +++ b/pkg/util/genutil/genutil.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package genutil import ( diff --git a/pkg/util/genutil/genutil_test.go b/pkg/util/genutil/genutil_test.go index 0ee85df27..050d14040 100644 --- a/pkg/util/genutil/genutil_test.go +++ b/pkg/util/genutil/genutil_test.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package genutil import ( diff --git a/tools/formitychecker/checker/checker.go b/tools/formitychecker/checker/checker.go index 187b509bc..7a1643358 100644 --- a/tools/formitychecker/checker/checker.go +++ b/tools/formitychecker/checker/checker.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package checker import ( diff --git a/tools/formitychecker/config/config.go b/tools/formitychecker/config/config.go index 95bcee346..0c4f6a16b 100644 --- a/tools/formitychecker/config/config.go +++ b/tools/formitychecker/config/config.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package config import ( diff --git a/tools/formitychecker/formitychecker.go b/tools/formitychecker/formitychecker.go index d078009b6..2bedbfb32 100644 --- a/tools/formitychecker/formitychecker.go +++ b/tools/formitychecker/formitychecker.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import ( diff --git a/tools/imctl/imctl.go b/tools/imctl/imctl.go index 1a501cafc..91161326e 100644 --- a/tools/imctl/imctl.go +++ b/tools/imctl/imctl.go @@ -1,3 +1,17 @@ +// Copyright © 2024 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import "fmt"