Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the CHATHISTORY extension specification. #292

Closed
wants to merge 30 commits into from
Closed
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d572c78
Add scrollback batch type
Jan 2, 2017
ff83973
Update copyright year
Jan 2, 2017
25c7e8d
Add RPL_ISUPPORT 005 to command specification
Jan 2, 2017
577d9c5
Add draft/msgid support to scrollback command
Jan 3, 2017
e2d46f5
Require batch reply
Jan 3, 2017
3871fa5
Make draft/msgid optional
Jan 3, 2017
ff2ef80
Reimplement extension using chathistory batch type
Jan 3, 2017
8ae7bf9
Update URLs
Jan 3, 2017
d261046
Rename scrollback to chathistory for consistency
Jan 3, 2017
c4883c0
Add max_message_count parameter to ISUPPORT
Jan 3, 2017
382968a
Add error replies and draft/label
Jan 4, 2017
ed14f4c
Specify label as draft
Jan 4, 2017
78b39f1
Improve error reporting and remove default size
Jan 10, 2017
78208a6
Make draft/label recommended
Jan 10, 2017
f923267
Specify optional draft/label
Jan 10, 2017
3ae7331
Specify work-in-progress draft implementation
Feb 13, 2017
0af7450
Allow for positive and negative directional message counts
Mar 7, 2017
77b4a6a
Typo fix
Mar 7, 2017
45b3e0a
Make draft/labeled-response recommended
Mar 8, 2017
e5f366b
Specificy draft/label and draft/msgid purposes
Mar 8, 2017
545f645
Specify draft/label and draft/msgid purposes
Mar 8, 2017
89b5299
Merge branch 'master' of https://github.com/MuffinMedic/ircv3-specifi…
Mar 8, 2017
23cb023
Merge branch 'master' of https://github.com/ircv3/ircv3-specifications
Apr 3, 2017
9cc586a
Standardize errors
Aug 23, 2017
d054b8b
Remove `draft/` from `CHATHISTORY` command
Aug 23, 2017
a210bfc
Remove WIP draft prefix requirement
Aug 23, 2017
4042cec
Change error codes to less-resemble existing numerics
Aug 25, 2017
8759f86
e and z
Aug 25, 2017
02aba74
n
Aug 25, 2017
88a3e1b
Merge branch 'master' of https://github.com/ircv3/ircv3-specifications
Nov 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions extensions/chathistory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: IRCv3 chathistory extension
layout: spec
work-in-progress: true
copyrights:
-
name: "Evan Magaliff"
period: "2017"
email: "evan@muffinmedic.net"
---
## Description
This document describes the format of the `chathistory` extension. The `chathistory` extension uses the [chathistory][batch/chathistory] batch type, adding a client-side command for requesting `chathistory` content from the server.

The `chathistory` extension adds an optional `draft/msgid` to the `chathistory` batch reply.

Clients MUST support the [`batch`][batch] and [`server-time`][server-time] capabilities. Clients SHOULD support the [`draft/labeled-response`][draft/labeled-response] and [`draft/message-tags`][draft/message-tags] capabilities.

When a client with the above mentioned capabilities requests `chathistory` content from the server (using the `CHATHISTORY` command outlined below), the server SHOULD return to the client a single batch containing raw IRC lines starting with and exluduing the `start` parameter and up to and including the message at the `end` parameter. The raw IRC lines SHOULD be formatted and returned to the client as they were originally, with the addition of the above capability tags.

The `server-time` SHOULD be the time at which the message was received from the IRC server and the `batch id` a unique ID for the entire batch. `draft/label` SHOULD be included and MUST be a unique ID used to identify the `chathistory` request and any replies. A `draft/msgid` to identify each individual message MUST be the `draft/msgid` included when each message was first received from the IRC server.

### `CHATHISTORY` Command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the spec say draft/CHATHISTORY command and use that in further examples? Since this spec does keep draft/msgid and not msgid in all examples.

`CHATHISTORY` content can be requested by the client to the server by sending the `CHATHISTORY` command to the server. A `batch` MUST be returned by the server. If no content exists to return, an empty batch SHOULD be returned to avoid the client waiting for a reply. Command support is sent to the client as the RPL_ISUPPORT 005 numeric `:irc.host 005 nick CHATHISTORY=max_message_count :are supported by this server`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead of "an empty batch ..." we could do "CHATHISTORY SUCCESS NOOP" / NO_DATA whatever can be returned


Both the `message_count` and `max_message_count` MUST be integers. `message_count` MUST be a non-zero and `max_message_count` MUST be greater than or equal to zero. The client SHOULD not request a `message_count` with an absolute value greater than the `max_message_count` parameter sent in the command.

Both the `start` and `end` parameters support `draft/msgid` and `timestamp`. The `end` parameter also accepts a `message_count`. If the number of lines between the `start` and `end` parameters exceeds the `max_message_count`, the server SHOULD return a number of lines equal to the `max_message_count` and the appropriate warning as described below. A `max_message_count` of 0 indicates that no maximum exists.

A positive `message_count` or tag `draft/msgid` prepended with a `+` indicates the client is requesting content after the `start`. A negative `message_count` or `draft/msgid` tag prepended with a `-` indicates the client is requested content before the specified `start`.

The `target` parameter specifies a single channel or query from which history SHOULD be retrieved. Wildcards or multiple targets are not supported.

#### Format
`chathistory` uses the following generic format:

@draft/label=ID CHATHISTORY <target> <start> <end>

The `chathistory` content can requested using timestamps:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might lead to some timing problems down the line, since the timestamp is not unique per message. A server may receive two messages at the very same time and only one of these make it to a connected client before it disconnects.

Then the client will reconnect and ask for messages since the last message it seen which would not include the missing message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to account for certain use cases in which draft/msgid tags are not available, such as in ZNC 1.6+ logs, in the format of YYYY-MM-DD.log [HH:mm:ss].


@draft/label=ID CHATHISTORY <target> timestamp=YYYY-MM-DDThh:mm:ss.sssZ message_count=<message_count>

Alternatively, content can be requested using a `draft/msgid`:

@draft/label=ID CHATHISTORY <target> draft/msgid=<message_id> timestamp=<timestamp>

Content can also be requested up to a specified timestamp or `draft/msgid` in place of the `message_count`. The start and end parameter types do not have to match:

@draft/label=ID CHATHISTORY <target> timestamp=<timestamp> +draft/msgid=<message_id>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp without an @ symbol?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp in this case is a command parameter, not a client tag.


#### Errors and Warnings
If the server receives a `CHATHISTORY` command with missing parameters, the `NEED_MORE_PARAMS` error code SHOULD be returned.

If the number of lines between the `start` and `end` parameters exceeds the `max_message_count`, warn code `MAX_MSG_COUNT_EXCEEDED` SHOULD be returned. The command SHOULD continue to be processed as described above.

If the target has no `chathistory` content to return or the user does not have permission to view the requested content, `NO_SUCH_NICK` or `NO_SUCH_CHANNEL` SHOULD be returned accordingly.

### Examples
The examples below are written with `draft/msgid` and `draft/label` tags included. These tags are recommended.

@draft/label=ID :irc.host BATCH +ID chathistory target

@batch=ID;draft/msgid=ID;time=YYYY-MM-DDThh:mm:ss.sssZ :nick!ident@host PRIVMSG target :message

@batch=ID;draft/msgid=ID;time=YYYY-MM-DDThh:mm:ss.sssZ :nick!ident@host NOTICE target :message

@batch=ID;draft/msgid=ID;time=YYYY-MM-DDThh:mm:ss.sssZ :nick!ident@host PRIVMSG target :ACTION message

:irc.host BATCH -ID

@draft/label=ID :nick!ident@host CHATHISTORY ERR ERR_CODE

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without explicitly mentioning ERR as a verb (and WARN) implementors may think that this is not a constant string and get confused. A reference to some sort of document explaining subcommands may be useful

@draft/label=ID :nick!ident@host CHATHISTORY WARN WARN_CODE

## Use Cases
The batch type and supporting command are useful for allowing an "infinite scroll" type capability within the client. A client will, upon scrolling to the top of the active window or a manual trigger, may request `chathistory` from the server and, after receiving returned content, append it to the top of the window. Users can repeat this historic scrolling to retrieve prior history until limitations are met (see below).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't CHATHISTORY command need to support requesting a range or messages before the given parameters. Currently it returns messages after a specified time or msgid. To implement this behaviour we would need to know the content before instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If message_count is positive, content MUST be retrieved from after and not including the specified timestamp or draft/msgid. If the message_count is negative, content MUST be retrieved from before the specified timestamp or draft/msgid.

The client is sending a known message as a starting point. If the oldest message a client has is at a particular time, this timestamp will be provided to CHATHISTORY and anything before it will be returned. The same goes for draft/msgid.

This works in the forward direction as well, in which the client knows the last message it has and wants to retrieve content from directly after it.

Theoretically, this works for any known message as a reference, and could be used to add context if a client wants to "jump" to a message, and then request X lines before and Y lines after.


## Limitations
Logging of messages and other actions MUST be enabled server-side and can be stored in any format desired, given appropriate software exists to retrieve and format such stored contnet. Scrollback can only be retrieved as far back as logs exist for the requesting user in the specified channel or query.

A method for securely identifying the requesting user MUST exist to ensure content is sent only to the appropriate users and clients. See below for more information.

## Security Considerations
Secure identification of users and clients MUST exist in order to ensure that users cannot obtain history they are not authorized to view. Use of account names, internal account identifiers, or certificate fingerprints SHOULD be strongly considered when matching content to users. The server MUST verify the current user's identity matches that of the desired content. This information is not sent as part of the `CHATHISTORY` command and MUST be validated via other means, such as those stated above. Access MUST be checked first and return an `NO_SUCH_NICK` or `NO_SUCH_CHANNEL` error as appropriate. If no authorization error exists, the server can check for returnable content. If no returntable content is found, the server MUST send an `NO_TEXT_TO_SEND` error. The server MUST NOT expose the existence of valid targets to unauthorized users.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(18:53:52) <Zarthus> before i make an ass out of myself
(18:53:58) <Zarthus> return an `NO_SUCH_NICK` or `NO_SUCH_CHANNEL` error
(18:54:04) <Zarthus> typo "an" -> "a" yes/no
(18:54:14) <Sadie> y

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUST send an NO_TEXT_TO_SEND error


While a `max_message_count` of 0 MAY be used to indicate no limit exists, servers SHOULD set and enforce a reasonable `max_message_count` and properly throttle `CHATHISTORY` commands to prevent abuse.

## Current Implementations
A ZNC-module implementation exists as [znc-chathistory](https://github.com/MuffinMedic/znc-chathistory). Client-side support for the ZNC module is in progress. Interest in supporting the batch type and command without ZNC has also been obtained, although specifics are not available at this time.

Note: This module may be out of date while the specification is reviewed and modified.

[batch]: http://ircv3.net/specs/extensions/batch-3.2.html
[batch/chathistory]: http://ircv3.net/specs/extensions/batch/chathistory-3.3.html
[server-time]: http://ircv3.net/specs/extensions/server-time-3.2.html
[draft/message-tags]: http://ircv3.net/specs/extensions/message-ids.html
[draft/labeled-response]: http://ircv3.net/specs/extensions/labeled-response.html