OurChat Api Document#

Status Code#

Note: The following status codes may occur in any case, so please ensure proper validation.

CodeId

CodeName

Meaning

0

OK

Execute successfully

13

INTERNAL

Internal Server Error

14

UNAVAILABLE

Under Maintenance

No further elaboration on the above special information

Please refer to grpc documentation

Api#

The message body itself is not elaborated here, please refer to the comments in the code

AuthService#

This Service is used for authentication in the server

Register#

Used to register a user and return its token

Error:

CodeId

CodeName

Detail

Meaning

6

ALREADY_EXISTS

User Already Exists

The email is conflicting with an existing user

333

INVALID_ARGUMENT

Password Is Not Strong Enough

The password is not strong enough

333

INVALID_ARGUMENT

Username Is Invalid

The username is invalid, for example, it is too long

333

INVALID_ARGUMENT

Email Address Is Invalid

It is not a valid address

Auth#

Used to log in an existing user and return its token

Error:

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

User Not Found

The user does not exist

333

INVALID_ARGUMENT

Missing AuthType

The AuthType argument is missing

16

UNAUTHENTICATED

Wrong Password

Password is incorrect

16

UNAUTHENTICATED

Account Locked

The account is locked

16

UNAUTHENTICATED

Email Not Verified

The email is not verified

Verify#

Used to initiate an email verification, to verify whether the account has been stolen

Error:

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

User Not Found

The user does not exist

333

INVALID_ARGUMENT

Missing AuthType

The AuthType argument is missing

16

UNAUTHENTICATED

Wrong Password

Password is incorrect

BasicService#

This Service is used to complete operations that do not require additional permissions on the server

GetServerInfo#

Get Server Information, including version number, etc.

No Error

GetId#

Through the account ocid to get the id of an account

Error:

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

User Not Found

The user does not exist

GetPresetUserStatus#

Get Preset User Social Status

Error:

CodeId

CodeName

Detail

Meaning

13

INTERNAL

Server Error

Internal Server Error

OurChatService#

This Service is used to complete most operations, and all operations require an additional token obtained through the AuthService

Provide the token by adding the request header: Authorization: Bearer <token>

It follows the RFC 6750 specification, and Bearer is the only supported authentication type currently.

The token itself is transmitted in the form of JWT, so you can decode the token. The data format in the token is:

{
  "id": 1, // account id(not ocid)
  "exp": 1600000000 // expiration time, this is unix timestamp
}

Once the token expires, the server will return the UNAUTHENTICATED error, and the error message will be Token Expired

If the token is invalid, such as not being a JWT or not containing the required fields, the server will return the UNAUTHENTICATED error, and the error message will be Token Invalid

If no token is provided, the server will return the UNAUTHENTICATED error, and the error message will be Token Missing

GetAccountInfo#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Insufficient permissions (e.g. accessing private information of a non-current account)

5

NOT_FOUND

User Not Found

User does not exist

333

INVALID_ARGUMENT

Request Invalid Value

Invalid request value (e.g. accessing a non-existent field)

SetSelfInfo#

CodeId

CodeName

Detail

Meaning

6

ALREADY_EXISTS

Conflict

Information conflict (e.g. the new ocid is occupied)

333

INVALID_ARGUMENT

Ocid Too Long

The new ocid is too long

333

INVALID_ARGUMENT

Status Too Long

The new status is too long

333

INVALID_ARGUMENT

Username Is Invalid

The username is invalid, for example, it is too long or empty

FetchMsgs#

CodeId

CodeName

Detail

Meaning

333

INVALID_ARGUMENT

Time Format Error

The structure of time cannot be parsed

333

INVALID_ARGUMENT

Time Missing

Argument time is required

SendMsg#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

You don’t have the privilege to send message here

5

NOT_FOUND

Session Not Found

The session does not exist

Upload#

CodeId

CodeName

Detail

Meaning

333

INVALID_ARGUMENT

File Size Error

The size of the data received is not equal to the size in metadata

333

INVALID_ARGUMENT

File Hash Error

The hash of the data received is not equal to the hash in metadata

8

RESOURCE_EXHAUSTED

Storage Full

The storage is full

333

INVALID_ARGUMENT

Metadata Error

The metadata is invalid or missing

333

INVALID_ARGUMENT

Incorrect Order Of Uploading

You should upload a package of metadata, then upload content package until process finish

Download#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

This file is not yours

NewSession#

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

User Not Found

The user you want to invite does not exist

DeleteSession#

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

Session Not Found

The session does not exist

333

INVALID_ARGUMENT

Request Invalid Value

Invalid request value (e.g. accessing a non-existent field)

SetSessionInfo#

CodeId

CodeName

Detail

Meaning

6

ALREADY_EXISTS

Conflict

The information should be set is conflict

7

PERMISSION_DENIED

Cannot Set Name

You don’t have the privilege to set name

7

PERMISSION_DENIED

Cannot Set Avatar

You don’t have the privilege to set avatar

7

PERMISSION_DENIED

Cannot Set Description

You don’t have the privilege to set description

RecallMsg#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

You don’t have the privilege to recall message

5

NOT_FOUND

Message Not Found

The message you want to recall does not exist

SetRole#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

You don’t have the privilege to set role

5

NOT_FOUND

User Not In Session

User does not exist

AddRole#

DeleteSession#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

You don’t have the privilege to delete session

5

NOT_FOUND

Session Not Found

The session does not exist

LeaveSession#

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

User Not In Session

User is not in this session

JoinInSession#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Cannot join in session, for example, user was banned

5

NOT_FOUND

Session Not Found

This session not exists

AcceptJoinInSession#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Cannot accept join in session request, for example, you don’t have this permission

5

NOT_FOUND

Session Not Found

This session not exists

MuteUser#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Don’t have MuteUser permission

UnmuteUser#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Don;t have UnmuteUser permission

5

NOT_FOUND

User Not Be Muted

User wasn’t be muted

BanUser#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Do not have BanUser permission

UnbanUser#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Do not have UnbanUser permission

5

NOT_FOUND

User Not Be Banned

The user is not banned

AddFriend#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Do not have permission

6

ALREADY_EXISTS

Friend Already Exists

The friend relationship already exists

5

NOT_FOUND

User Not Found

Friend does not exist

AcceptFriend#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Permission Denied

Do not have permission

5

NOT_FOUND

Friend Invitation Not Found

The friend request does not exist

DeleteFriend#

CodeId

CodeName

Detail

Meaning

5

NOT_FOUND

Friend Not Found

The friend relationship does not exist

GetRole#

CodeId

CodeName

Detail

Meaning

7

PERMISSION_DENIED

Not In Session

Not in the session, do not have permission

5

NOT_FOUND

Role Not Found

Role does not exist

Unregister#

No relevant errors can occur currently