mirror of
https://github.com/diamondburned/cchat.git
synced 2025-11-29 08:05:41 +00:00
Added ServerMessage{Editor,Actioner}
This commit is contained in:
parent
fa7f2fdca4
commit
231088e94d
|
|
@ -7,6 +7,13 @@ and frontend together.
|
||||||
|
|
||||||
## Backend
|
## Backend
|
||||||
|
|
||||||
|
Methods implemented by the backend that have frontend containers as arguments
|
||||||
|
should not do any IO. If IO is a must, they should be ran in goroutines, then
|
||||||
|
call the container callbacks when done. Other interface methods can do IO
|
||||||
|
normally.
|
||||||
|
|
||||||
|
*Note:* IO in most cases usually refer to networking, but they should include
|
||||||
|
files and such as well.
|
||||||
|
|
||||||
|
|
||||||
### Service
|
### Service
|
||||||
|
|
@ -116,6 +123,8 @@ A server is any entity that is usually a channel or a guild.
|
||||||
- ServerList and/or ServerMessage
|
- ServerList and/or ServerMessage
|
||||||
- ServerNickname
|
- ServerNickname
|
||||||
- Icon (optional)
|
- Icon (optional)
|
||||||
|
- ServerMessageEditor
|
||||||
|
- ServerMessageActioner
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
31
cchat.go
31
cchat.go
|
|
@ -143,8 +143,9 @@ type Server interface {
|
||||||
|
|
||||||
// ServerNickname extends Server to add a specific user nickname into a server.
|
// ServerNickname extends Server to add a specific user nickname into a server.
|
||||||
// The frontend should not traverse up the server tree, and thus the backend
|
// The frontend should not traverse up the server tree, and thus the backend
|
||||||
// must handle nickname inheritance. By default, the session name should be
|
// must handle nickname inheritance. This also means that servers that don't
|
||||||
// used.
|
// implement ServerMessage also don't need to implement ServerNickname. By
|
||||||
|
// default, the session name should be used.
|
||||||
type ServerNickname interface {
|
type ServerNickname interface {
|
||||||
Nickname(LabelContainer) error
|
Nickname(LabelContainer) error
|
||||||
}
|
}
|
||||||
|
|
@ -152,6 +153,9 @@ type ServerNickname interface {
|
||||||
// Icon is an extra interface that an interface could implement for an icon.
|
// Icon is an extra interface that an interface could implement for an icon.
|
||||||
// Typically, Service would return the service logo, Session would return the
|
// Typically, Service would return the service logo, Session would return the
|
||||||
// user's avatar, and Server would return the server icon.
|
// user's avatar, and Server would return the server icon.
|
||||||
|
//
|
||||||
|
// For session, the avatar should be the same as the one returned by messages
|
||||||
|
// sent by the current user.
|
||||||
type Icon interface {
|
type Icon interface {
|
||||||
Icon(IconContainer) error
|
Icon(IconContainer) error
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +193,29 @@ type ServerMessageSender interface {
|
||||||
SendMessage(SendableMessage) error
|
SendMessage(SendableMessage) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerMessageEditor optionally extends ServerMessage to add message editing
|
||||||
|
// capability to the server. These functions can have IO, and the frontend
|
||||||
|
// should take care of running them in goroutines.
|
||||||
|
type ServerMessageEditor interface {
|
||||||
|
// RawMessageContent gets the original message text for editing.
|
||||||
|
RawMessageContent(id string) (string, error)
|
||||||
|
// EditMessage edits the message with the given ID to the given content,
|
||||||
|
// which is the edited string from RawMessageContent.
|
||||||
|
EditMessage(id, content string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerMessageActioner optionally extends ServerMessage to add custom message
|
||||||
|
// action capabilities to the server. Similarly to ServerMessageEditor, these
|
||||||
|
// functions can have IO.
|
||||||
|
type ServerMessageActioner interface {
|
||||||
|
// MessageActions returns a list of possible actions in pretty strings that
|
||||||
|
// the frontend will use to directly display.
|
||||||
|
MessageActions() []string
|
||||||
|
// DoMessageAction executes a message action on the given messageID, which
|
||||||
|
// would be taken from MessageHeader.ID().
|
||||||
|
DoMessageAction(action, messageID string) error
|
||||||
|
}
|
||||||
|
|
||||||
// ServerMessageSendCompleter optionally extends ServerMessageSender to add
|
// ServerMessageSendCompleter optionally extends ServerMessageSender to add
|
||||||
// autocompletion into the message composer.
|
// autocompletion into the message composer.
|
||||||
type ServerMessageSendCompleter interface {
|
type ServerMessageSendCompleter interface {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue