Commit Graph

147 Commits

Author SHA1 Message Date
diamondburned 174496bdf9 Enforce Identifier on all Services
This commit breaks the Service interface to force all services to have a
global unique identifier. The commit does not enforce any particular
format, but the Reverse Domain Name Notation is recommended.

For reference:
https://en.wikipedia.org/wiki/Reverse_domain_name_notation
2021-03-19 16:52:41 -07:00
diamondburned da5c38eb2f Columnate to return bool
This commit breaks the previous Columnate API to return booleans instead
of constant integers. This makes handling Columnate API much simpler
with less false values (since all possible boolean values are valid).
2021-03-18 14:20:30 -07:00
diamondburned c2fb784dbf Move Columnate to Lister
This commit broke Lister to add Columnate, and the method is removed
from Server, because only Lister gets nested.
2021-03-18 12:27:50 -07:00
diamondburned d40f221221 Add missing return in Columnate 2021-03-18 10:06:52 -07:00
diamondburned ee9c2cc37c Remove redundant function 2021-03-18 09:58:13 -07:00
diamondburned 0569261f72 Enforce Columnate in Server
This commit breaks the API to enforce all servers to have a Columnate
method.

This commit also changes some of the documentation to be more obvious.
2021-03-18 09:52:14 -07:00
diamondburned 4ea6773527 Force ContainerMethod stop funcs
This commit breaks ContainerMethod to enforce explicit destructors. This
gives the frontend explicit control over when the container is
unsubscribed, but it also eases unsubscription implementations in the
backend.

With this new change, the backend can now add the container into a
global repository and unsubscribe from it explicitly from the callback.
2021-03-12 22:41:46 -08:00
diamondburned 1ece6ea076 Rename Author to Namer; Namer to use LabelContainer
This commit breaks more of the API to force all implementations of Namer
to use a LabelContainer instead of just returning a text. This is done
to allow updating of all labels instead of having to update the whole
parent context. This allows the backend to do book-keeping of labels and
images and trivially update them simultaneously without updating the
parent context.

The Author interface is also renamed to User. This allows the user
interface to be used everywhere else outside of Message.
2021-03-10 15:09:48 -08:00
diamondburned 1251001e8c Removed Icon interfaces, added ReadIndicator
This commit introduced a big breaking change of changing Author and
Namer to no longer have any reference to Icon or Image containers and
interfaces.

Instead, in the case of Author and Namer, it relies on the label being
updated by either an update setter or LabelContainer. The frontend
should get the first image/avatar to display that instead.

This commit also added ReadIndicator and related interfaces to support
the read receipts feature seen in Matrix, Telegram, Messenger and co.

The UnreadIndicator interface was broken to add the MarkRead method,
which hands explicit control of setting read messages for the current
user to the frontend instead.
2021-03-08 22:20:10 -08:00
diamondburned 41a7dac033 Added Columnator
This commit added the Columnator interface. This interface accommodates
the fact that some services (such as Discord) stylizes certain nested
servers in the same column.

This commit also fixed a minor test case.
2021-03-08 16:22:30 -08:00
diamondburned 02c686f994 Added helper methods to Package 2021-01-13 18:44:26 -08:00
diamondburned 1460ee6b4b Allow IOMethods to be explicit disposers
This commit changes IOMethods and clarifies stop functions that they
will act as destructors or disposers for whatever interface that
implements the methods, and that both the backend and frontend should
free that interface when they're called.

This commit is added as part of the IPC protocol.
2021-01-13 16:17:55 -08:00
diamondburned 06a26af5ba Slightly cleaner generation structure 2021-01-08 19:55:35 -08:00
diamondburned 903fe9fbfd Fixed ReplyingTo invalid type 2021-01-01 14:28:30 -08:00
diamondburned 7cb512f8b1 Added Replier and renamed Attachments
This commit renamed Attachments to Attacher, as the new name is more
idiomatic.

This commit also added the Replier interface, which is used to indicate
that a message being sent is a reply towards something.
2021-01-01 14:09:42 -08:00
diamondburned 24fc2c9bbb Fixed invalid types and bugs in MessageReferencer 2020-12-17 17:18:02 -08:00
diamondburned f1db8e0601 Added MessageReferencer for text.Rich
This commit added MessageReferencer for the text.Rich segments, which
allows a message to highlight a URL or text as a reference to other
messages. This could be used for replies as well as links that are
supposed to go to other messages.

The frontend gets to decide how exactly to represent the message when it
is clicked. However, as of right now, there is no API to fetch a single
message individually, so this API is limited to just within the message
buffer.
2020-12-17 17:14:21 -08:00
diamondburned 7fe9b3ed4c Clarified JoinServer opening n times
This commit clarifies that JoinServer must only be opened by one
container. In other words, before it is called again, the stop callback
of the last call must be called beforehand. This applies per messenger.
2020-12-17 16:47:38 -08:00
diamondburned fd8106eaf1 Revert Nonce deprecation
This commit reverts commit 9fd965d45a.

The reason for this reversion is that Send does not return an ID, and
therefore cannot know if any of its incoming messages are what it sent
or not.

Although a message return can be added into Send, that would be
extraneous, as the same message may now arrive by Send returning and/or
through the messenger container. Working around this would require
having an Upsert behavior instead of Insert or Update.
2020-12-17 12:44:52 -08:00
diamondburned 9fd965d45a Deprecated Nonce
This commit deprecates all Nonce methods as well as the concept of
Nonces in general. This is because in certain cases where coordination
between message sends and echoes would require far too much effort with
nonces as a method to detect message arrivals.

Starting from this commit, frontend implementations must assume that a
nil error returned from Sender's Send method means that the message has
successfully arrived.

Backend implementations must provide this guarantee if necessary by
blocking Send until it's sure that the message has arrived. For services
that send messages asynchronously, a handler and a blocking channel
(or pubsub) could be used to signal to the Send goroutine from the event
loop that the message has arrived. Backends may choose to transmit its
own nonces for this purpose.
2020-12-16 23:44:50 -08:00
diamondburned 955b99c9b6 Added AuthenticateError
This commit broke both the cchat API and its repository generation API
to accomodate for custom error types, as the new Authenticator API now
uses AuthenticateError over error to add in multi-stage authentication
instead of the old method with the for loop.

This commit also removed the multistage example documented in
Authenticator, as the API is now clearer.

This commit also added the WrapAuthenticateError helper function that
wraps a normal error into an AuthenticateError that does not have a
NextStage return. Backends should use this for
2020-10-27 13:33:52 -07:00
diamondburned c32c50c0e8 Changed Namer to a Name method in Authenticator
This commit removes the Namer interface and use a normal Name() method
instead. This is because we don't want to add icons into Authenticators.
2020-10-26 22:26:42 -07:00
diamondburned 318c85ab65 Added Namer and Description into Authenticator
This commit embeds the Namer interface into Authenticator as well as
adding the new Description method, both of which returns a text.Rich.
These methods are added to provide contextual clues to the user about
each Authenticator method.

Frontends can use the Name as the title, so the name should be short,
concise, and not include the name of the service.
2020-10-26 22:17:38 -07:00
diamondburned e59ab2dbf1 Clarified ID uniqueness
This commit clarifies the rules regarding ID uniqueness and guarantees
when it comes to the backend and frontend. This piece of documentation
was added into the top package section.
2020-10-26 21:50:01 -07:00
diamondburned ea2c12d119 Allow multiple implementations of Authenticator
This commit breaks the API to allow backends to return a slice of
Authenticators instead of a single Authenticator in the Service
interface. This is because some services might allow for more than one
method of authentication.

Note that the representation of multiple authenticators depends on the
frontend. One may choose to use tabs, notebooks, stacks, or anything
that is reasonable.
2020-10-26 21:49:57 -07:00
diamondburned 4c835a467b Fixed several ArgsIndexed bugs
This commit fixes several ArgsIndexed bugs that would cause the function
to return no words with -1. Additional test cases have been added.
2020-10-14 23:24:26 -07:00
diamondburned 10549e49e1 Added SplitFunc helper type
This commit adds the SplitFunc helper type which has a function
signature matching that of ArgsIndexer and SplitIndexer. Implementations
can use this type to provide pluggable splitters.
2020-10-14 18:26:49 -07:00
diamondburned 289eda1c25 Clarified Commander split rules; added ArgsIndexed
This commit clarified the word split rules when it comes to the
Commander interface. Specifically, this interface now has an edge case
of having split rules similarly to shell words (or shell syntax).

The implementation of these split rules is added into package split,
similarly to SplitIndexed. It is called ArgsIndexed. For the most parts,
it will behave similarly to shell syntax.
2020-10-14 18:08:35 -07:00
diamondburned 05f8ec0cbf Changed Commander to use []byte over io.Writer
This commit breaks the Commander interface. Prior to this, the Run
method would take in an io.Writer and do its tasks in the background.
Although this has lots of potential for usages, it is also very
overkill. Moreover, it makes IPC harder, since it now has to send over
fragments of data in synchronized order.

This commit gets rid of the io.Writer and only take a []byte for return
along with the error. This makes it easier for both the frontend and
backend to implement most commands, as well as making it easier for data
to be transferred over the wire.
2020-10-13 22:22:02 -07:00
diamondburned 1dd36e0034 Clarified text.Imager's bound behavior
This commit clarifies text.Imager's (and therefore text.Avatarer's as
well) bound behaviors. Prior to this commit, it is unclear which end
bound an implementation should return. This commit clarifies that in
order for the image to be inlined, the start must overlap the end
bounds.

This clarification was needed in order to differentiate images to be
inlined with images to be associated with other contexts, such as
Mentioned. The inline check would therefore be very simple:

    if start == end {
        if imager := segment.AsImager(); imager != nil {
            log.Println("Segment has an inline image.")
        }
    }

Note that since there's now a way to explicitly define whether an image
is inlined or not, for implementations that can't display images, the
ImageText() should only be used if the image is actually inlined.
Therefore, the same check also applies to ImageText(). This also applies
to AvatarText().
2020-10-13 18:30:21 -07:00
diamondburned 76f5201a6f Fix text.SolidColor returning invalid color
This commit fixes the implementation of the helper function SolidColor.
It now does correctly what it says: it sets the alpha bits to 0xFF.
Prior to this, the function would override part of the color due to an
incorrect shift.
2020-10-13 16:46:18 -07:00
diamondburned 4864d61476 Changed ServerUpdate's PreviousID API
Prior to this commit, the PreviousID method ambiguously confused two
different behaviors for the same result, that is when the returned ID is
empty.

This commit adds a return boolean to the method to differentiate those
two behaviors.
2020-10-09 12:11:23 -07:00
diamondburned 0ebf0c3302 Clarified ServerUpdate behavior
Prior to this commit, the PreviousID method of ServerUpdate seemed to be
a big unknown. This commit clarified that unknown by declaring two
conditions: when PreviousID returns an empty and non-empty ID.

The above change allows ServerUpdate events to both modify existing
servers as well as inserting new ones.
2020-10-09 11:51:16 -07:00
diamondburned d62231a4ef Fixed Backlogger method name
This commit fixes a mistake in the Backlogger interface, that is the
Backlog method was called Backlogger incorrectly.
2020-10-09 10:27:38 -07:00
diamondburned cfc0e00c8a Shorter, more idiomatic method names
This commit breaks several cchat interfaces to rename some method names
and make them shorter. These new method names are more idiomatic.
2020-10-09 10:09:38 -07:00
diamondburned 1b1e10a8a6 Updated reference split package to int64
This commit breaks package split's API to take in int64 types instead of
int. This is because CompletionEntry now uses int64 over int for
concreteness.
2020-10-09 09:34:02 -07:00
diamondburned 6140b5a131 Clarified text.{Imager,Avatarer}'s bound behavior
This commit clarifies text.Imager and text.Avatarer's bound behaviors.
Prior to this, the only behavior that those two interfaces have
regarding bounds is that only the starting bound matters, because images
must not substitute texts.

This commit clarifies that images are allowed complement other sections.
For example, a Mentioner can "have" an Imager by having the bounds
overlap.

These details are intentionally vaguely defined (it doesn't list any
interfaces beyond Mentioner), so implementations of either side can
implement these however they want, as long as the bounds overlap.

In the future, further clarification rules may be added if needed.
2020-10-09 00:17:58 -07:00
diamondburned 285ac6403f Added (text.Rich).IsEmpty
This commit restores the old IsEmpty API that was removed during code
generation.
2020-10-09 00:12:02 -07:00
diamondburned 819bcd3504 Clarified bitwise enum starting point; regenerate 2020-10-09 00:05:25 -07:00
diamondburned 32fa6266db Fixed Bitwise codegen being flipped 2020-10-08 23:58:58 -07:00
diamondburned 89b5ede1d8 Regenerated code to adhere to codegen header
This commit regenerates all files to adhere to the arguably-official
convention of having a standardized comment format to allow
distinguishing between written and generated files.

Refer to https://golang.org/s/generatedcode for more information.
2020-10-04 14:33:57 -07:00
diamondburned 5f7316cf9d Actioner.Actions to take a message ID
This commit restores the old API prior to the repository commits to make
the Actions method of the Actioner interface take in a message ID and
return a slice of strings.
2020-10-04 11:45:18 -07:00
diamondburned 086f987b3c Add Stringer into struct repositories
This commit adds the Stringer method representation into the repository.
The Rich struct of package text now implements Stringer and returns the
Content in plain text.

Prior to the repository commits, Rich used to have String().
2020-10-04 10:28:48 -07:00
diamondburned e08064021e Reproducible empty interface code generation
Prior to this commit, the code generator for package empty doesn't have
a defined order. This commit now sorts the packages before generation,
which gets rid of the main map's undefined order.
2020-10-03 23:24:15 -07:00
diamondburned dd4e230e0f Fixed UnreadContainer's comment
Prior to this commit, UnreadContainer's comments mentioned deprecated
SetUnread and such methods. It now reflects the new API.
2020-10-03 23:17:32 -07:00
diamondburned 99f7224d32 Mentioned now returns bool
Prior to this commit, the Mentioned method in MessageCreate didn't
return anything. This is a regression. It now returns a boolean that
indicates mentioned.
2020-10-03 23:14:54 -07:00
diamondburned 555931f974 Added Avatar() into Author
This commit adds the Avatar method into the Author interface. It returns
the URL if one, or it can return an empty string if either the service
does not support avatars or the user doesn't have avatars.
2020-10-03 23:08:24 -07:00
diamondburned aaa29f35b0 Author now has Name() over Namer
Prior to this commit, interface Author embedded interface Namer. This
doesn't work, as it is discouraged to keep a working state inside the
implementation of Author, but Namer's embedded Iconer requires a state.

The commit changed Author to use a Name method instead, which is only a
getter. It will no longer satisfy interface Name.
2020-10-03 22:52:21 -07:00
diamondburned 1588cfef9c Fixed IconContainer.SetIcon; added ImageContainer
This commit fixes IconContainer's SetIcon, which was SetImage prior to
this commit. Before the code generation commits, this container
originally had SetIcon.

This commit also adds back ImageContainer, which was a regression during
the code generation changes. It has the SetImage method.
2020-10-03 22:06:50 -07:00
diamondburned e2751cc260 Added helper functions in package text
This package adds back the Plain function from the old package text as
well as a new function called SolidColor that returns a new RGBA color
with the alpha bits maxed out.

These functions are there for convenience. They're also outside the
scope of the code generator and repository.
2020-10-03 21:29:15 -07:00