Files
open-im-server/pkg/common/constant/constant.go
T

364 lines
10 KiB
Go
Raw Normal View History

2023-07-04 11:15:20 +08:00
// Copyright © 2023 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.
2023-06-29 22:35:31 +08:00
package constant
const (
///ContentType
2023-07-13 17:37:51 +08:00
//UserRelated.
ContentTypeBegin = 100
Text = 101
Picture = 102
Voice = 103
Video = 104
File = 105
AtText = 106
Merger = 107
Card = 108
Location = 109
Custom = 110
Revoke = 111
Typing = 113
Quote = 114
2023-06-30 09:45:02 +08:00
AdvancedText = 117
CustomNotTriggerConversation = 119
CustomOnlineOnly = 120
ReactionMessageModifier = 121
ReactionMessageDeleter = 122
Common = 200
GroupMsg = 201
SignalMsg = 202
CustomNotification = 203
2023-06-29 22:35:31 +08:00
// SysRelated.
2023-06-29 22:35:31 +08:00
NotificationBegin = 1000
2023-07-13 17:37:51 +08:00
FriendApplicationApprovedNotification = 1201 // add_friend_response
FriendApplicationRejectedNotification = 1202 // add_friend_response
FriendApplicationNotification = 1203 // add_friend
2023-06-29 22:35:31 +08:00
FriendAddedNotification = 1204
2023-07-13 17:37:51 +08:00
FriendDeletedNotification = 1205 // delete_friend
FriendRemarkSetNotification = 1206 // set_friend_remark?
BlackAddedNotification = 1207 // add_black
BlackDeletedNotification = 1208 // remove_black
2023-06-30 09:45:02 +08:00
FriendInfoUpdatedNotification = 1209
2023-06-29 22:35:31 +08:00
2023-06-30 09:45:02 +08:00
ConversationChangeNotification = 1300 // change conversation opt
2023-06-29 22:35:31 +08:00
UserNotificationBegin = 1301
2023-07-13 17:37:51 +08:00
UserInfoUpdatedNotification = 1303 // SetSelfInfoTip = 204
2023-06-29 22:35:31 +08:00
UserNotificationEnd = 1399
OANotification = 1400
GroupNotificationBegin = 1500
2023-06-30 09:45:02 +08:00
GroupCreatedNotification = 1501
GroupInfoSetNotification = 1502
JoinGroupApplicationNotification = 1503
MemberQuitNotification = 1504
GroupApplicationAcceptedNotification = 1505
GroupApplicationRejectedNotification = 1506
GroupOwnerTransferredNotification = 1507
MemberKickedNotification = 1508
MemberInvitedNotification = 1509
MemberEnterNotification = 1510
GroupDismissedNotification = 1511
GroupMemberMutedNotification = 1512
GroupMemberCancelMutedNotification = 1513
GroupMutedNotification = 1514
GroupCancelMutedNotification = 1515
GroupMemberInfoSetNotification = 1516
GroupMemberSetToAdminNotification = 1517
GroupMemberSetToOrdinaryUserNotification = 1518
GroupInfoSetAnnouncementNotification = 1519
GroupInfoSetNameNotification = 1520
2023-06-29 22:35:31 +08:00
SignalingNotificationBegin = 1600
SignalingNotification = 1601
2022-05-30 12:12:09 +08:00
SignalingNotificationEnd = 1649
SuperGroupNotificationBegin = 1650
2022-05-30 18:23:12 +08:00
SuperGroupUpdateNotification = 1651
2023-06-30 09:45:02 +08:00
MsgDeleteNotification = 1652
2022-05-30 12:12:09 +08:00
SuperGroupNotificationEnd = 1699
2023-06-29 22:35:31 +08:00
ConversationPrivateChatNotification = 1701
2023-06-30 09:45:02 +08:00
ConversationUnreadNotification = 1702
MsgRevokeNotification = 2101
BusinessNotificationBegin = 2000
BusinessNotification = 2001
BusinessNotificationEnd = 2099
2023-06-29 22:35:31 +08:00
2023-06-30 09:45:02 +08:00
ClearConversationNotification = 2101
DeleteMsgsNotification = 2102
2022-04-18 15:45:44 +08:00
2023-06-30 09:45:02 +08:00
HasReadReceipt = 2200
NotificationEnd = 5000
2023-06-29 22:35:31 +08:00
// status.
2023-06-29 22:35:31 +08:00
MsgNormal = 1
MsgDeleted = 4
// MsgFrom.
2023-06-29 22:35:31 +08:00
UserMsgType = 100
SysMsgType = 200
// SessionType.
2023-06-30 09:45:02 +08:00
SingleChatType = 1
GroupChatType = 2
SuperGroupChatType = 3
2023-06-29 22:35:31 +08:00
NotificationChatType = 4
// token.
2023-06-29 22:35:31 +08:00
NormalToken = 0
InValidToken = 1
KickedToken = 2
ExpiredToken = 3
// MultiTerminalLogin.
2023-06-30 09:45:02 +08:00
DefalutNotKick = 0
// Full-end login, but the same end is mutually exclusive.
2023-06-29 22:35:31 +08:00
AllLoginButSameTermKick = 1
// Only one of the endpoints can log in.
2023-06-29 22:35:31 +08:00
SingleTerminalLogin = 2
// The web side can be online at the same time, and the other side can only log in at one end.
2023-06-29 22:35:31 +08:00
WebAndOther = 3
2023-07-03 16:29:22 +08:00
// The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at
2023-07-13 17:37:51 +08:00
// the same time.
2023-06-29 22:35:31 +08:00
PcMobileAndWeb = 4
// The PC terminal can be online at the same time,but other terminal only one of the endpoints can login.
2023-06-30 09:45:02 +08:00
PCAndOther = 5
2023-06-29 22:35:31 +08:00
OnlineStatus = "online"
OfflineStatus = "offline"
Registered = "registered"
UnRegistered = "unregistered"
// MsgReceiveOpt.
2023-06-29 22:35:31 +08:00
ReceiveMessage = 0
NotReceiveMessage = 1
ReceiveNotNotifyMessage = 2
// OptionsKey.
2023-06-29 22:35:31 +08:00
IsHistory = "history"
IsPersistent = "persistent"
IsOfflinePush = "offlinePush"
IsUnreadCount = "unreadCount"
IsConversationUpdate = "conversationUpdate"
IsSenderSync = "senderSync"
IsNotPrivate = "notPrivate"
IsSenderConversationUpdate = "senderConversationUpdate"
2022-05-18 18:37:42 +08:00
IsSenderNotificationPush = "senderNotificationPush"
2023-06-30 09:45:02 +08:00
IsReactionFromCache = "reactionFromCache"
IsNotNotification = "isNotNotification"
IsSendMsg = "isSendMsg"
2023-06-29 22:35:31 +08:00
// GroupStatus.
2023-06-29 22:35:31 +08:00
GroupOk = 0
GroupBanChat = 1
GroupStatusDismissed = 2
GroupStatusMuted = 3
// GroupType.
2023-06-30 09:45:02 +08:00
NormalGroup = 0
SuperGroup = 1
WorkingGroup = 2
2022-05-12 19:00:48 +08:00
2023-06-29 22:35:31 +08:00
GroupBaned = 3
GroupBanPrivateChat = 4
// UserJoinGroupSource.
2023-06-29 22:35:31 +08:00
JoinByAdmin = 1
2023-06-30 09:45:02 +08:00
JoinByInvitation = 2
JoinBySearch = 3
JoinByQRCode = 4
// Minio.
2023-06-29 22:35:31 +08:00
MinioDurationTimes = 3600
// Aws.
2023-06-30 09:45:02 +08:00
AwsDurationTimes = 3600
2023-06-29 22:35:31 +08:00
// callbackCommand.
2023-06-30 09:45:02 +08:00
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroupCommand"
CallbackBeforeMemberJoinGroupCommand = "callbackBeforeMemberJoinGroupCommand"
CallbackBeforeSetGroupMemberInfoCommand = "CallbackBeforeSetGroupMemberInfoCommand"
CallbackBeforeSetMessageReactionExtensionCommand = "callbackBeforeSetMessageReactionExtensionCommand"
CallbackBeforeDeleteMessageReactionExtensionsCommand = "callbackBeforeDeleteMessageReactionExtensionsCommand"
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
// callback actionCode.
2023-06-29 22:35:31 +08:00
ActionAllow = 0
ActionForbidden = 1
// callback callbackHandleCode.
2023-06-29 22:35:31 +08:00
CallbackHandleSuccess = 0
CallbackHandleFailed = 1
2023-07-13 17:37:51 +08:00
// minioUpload.
2023-06-29 22:35:31 +08:00
OtherType = 1
VideoType = 2
ImageType = 3
2023-06-30 09:45:02 +08:00
2023-07-13 17:37:51 +08:00
// sendMsgStaus.
2023-06-30 09:45:02 +08:00
MsgStatusNotExist = 0
MsgIsSending = 1
MsgSendSuccessed = 2
MsgSendFailed = 3
2023-06-29 22:35:31 +08:00
)
2023-06-30 09:45:02 +08:00
const (
WriteDiffusion = 0
ReadDiffusion = 1
)
const (
UnreliableNotification = 1
ReliableNotificationNoMsg = 2
ReliableNotificationMsg = 3
)
2022-04-22 15:12:10 +08:00
const (
2023-06-30 09:45:02 +08:00
AtAllString = "AtAllTag"
AtNormal = 0
AtMe = 1
AtAll = 2
AtAllAtMe = 3
GroupNotification = 4
2022-04-22 15:12:10 +08:00
)
2023-06-29 22:35:31 +08:00
var ContentType2PushContent = map[int64]string{
2023-06-30 09:45:02 +08:00
Picture: "[PICTURE]",
Voice: "[VOICE]",
Video: "[VIDEO]",
File: "[File]",
Text: "[TEXT]",
AtText: "[@TEXT]",
GroupMsg: "[GROUPMSG]]",
Common: "[NEWMSG]",
SignalMsg: "[SIGNALINVITE]",
2023-06-29 22:35:31 +08:00
}
2022-04-24 15:55:19 +08:00
const (
2022-04-24 17:27:26 +08:00
FieldRecvMsgOpt = 1
FieldIsPinned = 2
FieldAttachedInfo = 3
FieldIsPrivateChat = 4
FieldGroupAtType = 5
FieldEx = 7
2022-07-26 21:02:11 +08:00
FieldUnread = 8
2023-06-30 09:45:02 +08:00
FieldBurnDuration = 9
FieldHasReadSeq = 10
2022-04-24 15:55:19 +08:00
)
2023-06-29 22:35:31 +08:00
const (
AppOrdinaryUsers = 1
AppAdmin = 2
2023-06-30 09:45:02 +08:00
GroupOwner = 100
GroupAdmin = 60
GroupOrdinaryUsers = 20
2023-06-29 22:35:31 +08:00
GroupResponseAgree = 1
GroupResponseRefuse = -1
2023-07-13 15:26:25 +08:00
FriendResponseNotHandle = 0
FriendResponseAgree = 1
FriendResponseRefuse = -1
2023-06-29 22:35:31 +08:00
Male = 1
Female = 2
)
2023-07-13 17:37:51 +08:00
const (
OperationID = "operationID"
OpUserID = "opUserID"
ConnID = "connID"
OpUserPlatform = "platform"
Token = "token"
RpcCustomHeader = "customHeader" // rpc中间件自定义ctx参数
CheckKey = "CheckKey"
TriggerID = "triggerID"
RemoteAddr = "remoteAddr"
)
2023-06-30 09:45:02 +08:00
2023-06-29 22:35:31 +08:00
const (
2023-07-13 17:37:51 +08:00
BecomeFriendByImport = 1 // 管理员导入
BecomeFriendByApply = 2 // 申请添加
2023-06-30 09:45:02 +08:00
)
const (
ApplyNeedVerificationInviteDirectly = 0 // 申请需要同意 邀请直接进
2023-07-13 17:37:51 +08:00
AllNeedVerification = 1 // 所有人进群需要验证,除了群主管理员邀请进群
Directly = 2 // 直接进群
2023-06-30 09:45:02 +08:00
)
const (
GroupRPCRecvSize = 30
GroupRPCSendSize = 30
2023-06-29 22:35:31 +08:00
)
const FriendAcceptTip = "You have successfully become friends, so start chatting"
func GroupIsBanChat(status int32) bool {
if status != GroupStatusMuted {
return false
}
return true
}
func GroupIsBanPrivateChat(status int32) bool {
if status != GroupBanPrivateChat {
return false
}
return true
}
const LogFileName = "OpenIM.log"
2023-06-30 09:45:02 +08:00
const LocalHost = "0.0.0.0"
2023-07-13 17:37:51 +08:00
// flag parse.
2023-06-30 09:45:02 +08:00
const (
FlagPort = "port"
FlagWsPort = "ws_port"
FlagPrometheusPort = "prometheus_port"
FlagConf = "config_folder_path"
)
const OpenIMCommonConfigKey = "OpenIMServerConfig"
const CallbackCommand = "command"
2023-07-14 18:54:56 +08:00
const BatchNum = 100