This commit is contained in:
Troplo 2022-06-05 22:58:18 +10:00
parent 21b767abc2
commit 87302afa1d
135 changed files with 236816 additions and 0 deletions

3
.browserslistrc Normal file
View file

@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead

9
.env.example Normal file
View file

@ -0,0 +1,9 @@
VUE_APP_VERSION=[AIV]{version}[/AIV]
VUE_APP_BUILD_DATE=[AIV]{date}[/AIV]
VUE_APP_SENTRY_DSN=https://c82c997e304148cf8deed40fef8912ea@o444992.ingest.sentry.io/6307174
VUE_APP_MATOMO_SITE_ID=5
VUE_APP_MATOMO_URL=https://analytics.flowinity.com
VUE_APP_MATOMO_TRACKER=flow
VUE_APP_MATOMO_DOMAINS=*.troplo.com
VUE_APP_MATOMO_ENABLED=true
VUE_APP_SENTRY_ENABLED=true

19
.eslintrc.js Normal file
View file

@ -0,0 +1,19 @@
module.exports = {
root: true,
env: {
es2020: true,
node: true
},
extends: ["plugin:vue/essential", "eslint:recommended"],
parserOptions: {
parser: "babel-eslint"
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"vue/no-parsing-error": [
"error",
{ "invalid-first-character-of-tag-name": false }
]
}
}

4
.prettierignore Normal file
View file

@ -0,0 +1,4 @@
# Ignore artifacts:
dist
public
patches

13
.prettierrc Normal file
View file

@ -0,0 +1,13 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "always"
}

674
LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

2
NOTICE Normal file
View file

@ -0,0 +1,2 @@
Colubrina or Troplo/Colubrina is a simple chatting platform that allows you to communicate with people over websockets.
Licensed under GNU GPLv3, and based off of the original BetterCompass Communications by @Troplo.

34
README.md Normal file
View file

@ -0,0 +1,34 @@
# Colubrina
![Wakatime](https://wakatime.troplo.com/api/badge/Troplo/interval:any/project:Colubrina?label=wakatime)
## Project setup
Rename .env.example to .env and fill it out with your own information.
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn serve
```
### Compiles and minifies for production
```
yarn build
```
### Lints and fixes files
```
yarn lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
#### View the Colubrina license in the LICENSE file.

10
SECURITY.md Normal file
View file

@ -0,0 +1,10 @@
# Security Policy
## Reporting a Vulnerability
If you find a vulnerability of any kind, please email me
at [troplo@troplo.com](mailto:troplo@troplo.com).
PLEASE DO NOT MAKE A PULL REQUEST FOR SECURITY VULNERABILITIES.
Thank you.

4
babel.config.js Normal file
View file

@ -0,0 +1,4 @@
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"],
plugins: [["@babel/plugin-proposal-optional-chaining"]]
}

6
backend/.env.example Normal file
View file

@ -0,0 +1,6 @@
HOSTNAME=localhost
RELEASE=dev
NOTIFICATION=
WEATHER_API_KEY=OpenWeatherMap API Key
PARENT_LINK=[{"intendedFor": [0], "instance": "compass-vic", "userId": 1, "token": "aaaaaaaa-bbbbbbbb-cccccccc-dddddddd", "whitelistedSenderIds": []}]
NOTIFICATION_TYPE=info

4
backend/.prettierignore Normal file
View file

@ -0,0 +1,4 @@
# Ignore artifacts:
dist
public
patches

13
backend/.prettierrc Normal file
View file

@ -0,0 +1,13 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "always"
}

674
backend/LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

4
backend/NOTICE Normal file
View file

@ -0,0 +1,4 @@
BetterCompass is created and maintained by GitHub user @Troplo, and Gitea user https://git.troplo.com/Troplo, and is licensed under the GNU GENERAL PUBLIC LICENSE Version 3, which can be found in the LICENSE file at the root of this project.
The source code is available on both Gitea, and GitHub respectively, https://git.troplo.com/Troplo/compass-vue, and https://github.com/Troplo/BetterCompass
BetterCompass Proxy is provided with the BetterCompass software, and has the same license.

14
backend/README.md Normal file
View file

@ -0,0 +1,14 @@
# Colubrina Backend
## Setup instructions
- Run `yarn install` to install the dependencies.
- Configure the MariaDB database connection in `config/config.json` using the
example template `config/config.example.json`.
- Configure `.env` with the template `.env.example`.
- Run `sequelize db:migrate` to create the database tables.
- Run `sequelize db:seed` to seed required information to the database.
- Run `yarn serve` to start the proxy with nodemon which automatically restarts
on file-change for development.
- Run `yarn start` or `node .` to start the proxy in production.
- Colubrina Proxy runs on port 23998.

View file

@ -0,0 +1,23 @@
{
"development": {
"username": "username",
"password": "password",
"database": "database",
"host": "host",
"dialect": "mariadb"
},
"test": {
"username": "username",
"password": "password",
"database": "database",
"host": "host",
"dialect": "mariadb"
},
"production": {
"username": "username",
"password": "password",
"database": "database",
"host": "host",
"dialect": "mariadb"
}
}

54
backend/index.js Normal file
View file

@ -0,0 +1,54 @@
console.log("Initializing")
require("dotenv").config()
let express = require("express")
let app = express()
let bodyParser = require("body-parser")
let os = require("os")
const cookieParser = require("cookie-parser")
app.use(cookieParser())
app.set("trust proxy", true)
const socket = require("./lib/socket")
const server = require("http").createServer(app)
app.use(bodyParser.json({ limit: "15mb" }))
app.use(bodyParser.urlencoded({ extended: true }))
app.use("/api/v1/user", require("./routes/user.js"))
app.use("/api/v1/themes", require("./routes/theme.js"))
app.use("/api/v1/communications", require("./routes/communications.js"))
app.use("/api/v1/admin", require("./routes/admin.js"))
app.use("/usercontent", require("./routes/usercontent.js"))
app.use("/api/v1/usercontent", require("./routes/usercontent.js"))
app.use("/api/v1/mediaproxy", require("./routes/mediaproxy.js"))
app.get("/api/v1/state", async (req, res) => {
res.json({
release: process.env.RELEASE,
loading: true,
notification: process.env.NOTIFICATION,
notificationType: process.env.NOTIFICATION_TYPE,
latestVersion: require("../package.json").version,
name: "Colubrina"
})
})
app.all("/api/*", (req, res) => {
res.status(404).json({
message: "Route not found."
})
})
console.log(os.hostname())
app.use(require("./lib/errorHandler"))
server.listen(23998, () => {
console.log("Initialized")
console.log("Listening on port 0.0.0.0:" + 23998)
app.locals.appStarted = true
app.emit("appStarted")
})
socket.init(app, server)
module.exports = app

43
backend/lib/authorize.js Normal file
View file

@ -0,0 +1,43 @@
const { User, Theme, Session } = require("../models")
const Errors = require("./errors")
module.exports = async function (req, res, next) {
try {
if (req.header("Authorization") && req.header("Authorization") !== "null") {
const token = req.header("Authorization")
const session = await Session.findOne({ where: { session: token } })
if (session) {
const user = await User.findOne({
where: { id: session.userId },
attributes: {
exclude: ["totp", "password"]
},
include: [
{
model: Theme,
as: "themeObject"
}
]
})
if (user) {
await user.update({
lastSeenAt: new Date().toISOString()
})
req.user = user
next()
}
} else {
res.status(401).json(Errors.unauthorized)
}
} else {
res.status(401).json({
errors: [
{
message: "You need to be logged in."
}
]
})
}
} catch (e) {
console.log(e)
}
}

View file

@ -0,0 +1,45 @@
const { User, Theme, Session } = require("../models")
const parseCookie = (str) =>
str
.split(";")
.map((v) => v.split("="))
.reduce((acc, v) => {
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim())
return acc
}, {})
module.exports = async function (socket, next) {
try {
const cookies = parseCookie(socket.handshake.headers.cookie)
if (cookies["session"]) {
const session = await Session.findOne({
where: { session: cookies["session"] }
})
if (session) {
const user = await User.findOne({
where: { id: session.userId },
attributes: {
exclude: ["totp", "password"]
},
include: [
{
model: Theme,
as: "themeObject"
}
],
raw: true
})
if (user) {
socket.user = user
next()
}
} else {
//
}
} else {
//
}
} catch (error) {
//
}
}

186644
backend/lib/blacklist.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
Based on StephenBlack/hosts base + pornography

View file

@ -0,0 +1,17 @@
let { Sequelize } = require("../models")
let Errors = require("./errors")
module.exports = function (err, req, res, next) {
if (err instanceof Sequelize.ValidationError) {
res.status(400).json(err)
} else if (err.name in Errors) {
res.status(err.status).json({
errors: [err]
})
} else {
console.error(err)
res.status(500).json({
errors: [Errors.unknown]
})
}
}

100
backend/lib/errors.js Normal file
View file

@ -0,0 +1,100 @@
let Errors = {
unknown: ["Something went wrong.", 500],
unauthorized: ["You don't have permission to do that.", 401],
notAuthenticated: ["You have to login to do that", 401],
userNotOptedIn: [
"You have to opt in to BetterCompass Accounts to do that.",
401
],
invalidUserOrPassword: ["Invalid username or password.", 401],
parentLinkIneligible: ["Your school does not support ParentLink.", 401],
invalidTotp: ["Invalid 2FA code.", 401],
invalidCredentials: ["Invalid username or password.", 401],
bcSessionsForced: [
"You are attempting to login as a user that enforces BetterCompass Sessions.\nBetterCompass extended functionality is disabled for this session instance.",
401
],
rateLimit: [
"You are being rate-limited. Please try again in a few minutes.",
429
],
communicationsUserNotFound: ["This user does not exist.", 400],
communicationsUserNotOptedIn: [
"This user has not opted in to BetterCompass Communications.",
400
],
friendAlreadyFriends: ["You are already friends with this user.", 400],
friendNotFound: ["The friend instance couldn't be found.", 400],
chatNotFoundOrNotAdmin: [
"The chat instance couldn't be found, or you are not an administrator of it.",
400
],
experimentsOptIn: ["You are not opted into this experiment.", 401],
attachmentNotFound: [
"The user content you are trying to access does not exist, or has been deleted.",
400
],
invalidFileType: [
"The file you are trying to upload is not a valid file type.",
400
],
fileTooLarge: ["The file you are trying to upload is too large.", 400],
unauthorizedInstance: [
"You are not authorized to access BetterCompass.",
401
],
invalidPassword: [
"Your password must be at least 8 characters in length.",
400
]
}
function processErrors(errorName) {
let arr = Errors[errorName]
temp = {}
temp.name = errorName
temp.message = arr[0]
temp.status = arr[1]
return {
name: errorName,
message: arr[0],
status: arr[1]
}
}
let ProcessedErrors = {}
for (let errorName in Errors) {
ProcessedErrors[errorName] = processErrors(errorName)
}
ProcessedErrors.VALIDATION_ERROR = "VALIDATION_ERROR"
ProcessedErrors.invalidParameter = function (param, message) {
let punctuatedMessage = ""
if (message) {
punctuatedMessage = ": " + message
}
return {
name: "invalidParameter",
message: `${param} is invalid${punctuatedMessage}`,
status: 400,
parameter: param
}
}
ProcessedErrors.sequelizeValidation = (sequelize, obj) => {
return new sequelize.ValidationError(obj.error, [
new sequelize.ValidationErrorItem(
obj.error,
"Validation error",
obj.path,
obj.value
)
])
}
module.exports = ProcessedErrors

View file

@ -0,0 +1,99 @@
const { Message } = require("../models")
const axios = require("axios")
const ogs = require("open-graph-scraper")
const cryptoRandomString = require("crypto-random-string")
const blacklist = require("./blacklist.json")
module.exports = async function (req, message) {
return new Promise(async (resolve, reject) => {
try {
if (message.content) {
const regex = /(https?:\/\/[^\s]+)/g
let links = message.content.match(regex)
if (links && links.length > 3) {
links = links.slice(0, 3)
}
let embeds = []
if (links) {
for (let [i, link] of links.entries()) {
const linkURL = new URL(link)
if (blacklist.includes(linkURL.hostname)) {
console.log("Blacklisted link " + linkURL.hostname)
embeds.push({
link: link,
type: "openGraph",
openGraph: {
ogTitle: "Blacklisted link",
ogDescription:
"This link cannot be mediaproxied at this time."
}
})
continue
}
await ogs({
url: link,
followRedirect: true,
followAllRedirects: true,
headers: {
"user-agent": "Googlebot/2.1 (+http://www.google.com/bot.html)"
}
})
.then(({ result }) => {
if (result) {
embeds.push({
openGraph: result,
link: link,
type: "openGraph"
})
}
})
.catch(async (e) => {
await axios
.get(link, {
headers: {
"user-agent":
"Googlebot/2.1 (+http://www.google.com/bot.html)"
}
})
.then((res) => {
// if content type is image
if (res.headers["content-type"].startsWith("image/")) {
const securityToken = cryptoRandomString({ length: 32 })
embeds.push({
type: "image",
link: link,
securityToken,
mediaProxyLink:
"/api/v1/mediaproxy/" +
message.id +
"/" +
i +
"/" +
securityToken
})
}
})
.catch(() => {})
})
}
await Message.update(
{
embeds: embeds
},
{
where: {
id: message.id
}
}
)
resolve(embeds)
} else {
reject()
}
} else {
reject()
}
} catch (err) {
console.log(err)
}
})
}

104
backend/lib/socket.js Normal file
View file

@ -0,0 +1,104 @@
const auth = require("../lib/authorize_socket.js")
const { User, Friend } = require("../models")
module.exports = {
init(app, server) {
const io = require("socket.io")(server, {
cors: {
origin: [process.env.CORS_HOSTNAME],
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"]
}
})
io.use(auth)
io.on("connection", async (socket) => {
const user = await User.findOne({
where: {
id: socket.user.id
}
})
socket.join(user.id)
socket.emit("siteState", {
release: process.env.RELEASE,
notification: process.env.NOTIFICATION,
notificationType: process.env.NOTIFICATION_TYPE,
latestVersion: require("../../package.json").version
})
const friends = await Friend.findAll({
where: {
userId: user.id,
status: "accepted"
}
})
await user.update({
status:
user.storedStatus === "invisible" ? "offline" : user.storedStatus
})
friends.forEach((friend) => {
io.to(friend.friendId).emit("userStatus", {
userId: user.id,
status:
user.storedStatus === "invisible" ? "offline" : user.storedStatus
})
})
socket.on("ping", () => {
socket.emit("pong")
})
socket.on("idle", async () => {
const user = await User.findOne({
where: {
id: socket.user.id
}
})
if (user.storedStatus === "online") {
friends.forEach((friend) => {
io.to(friend.friendId).emit("userStatus", {
userId: user.id,
status: "away"
})
})
io.to(user.id).emit("userStatus", {
userId: user.id,
status: "away"
})
await user.update({
status: "away"
})
}
})
socket.on("online", async () => {
const user = await User.findOne({
where: {
id: socket.user.id
}
})
if (user.storedStatus === "online") {
friends.forEach((friend) => {
io.to(friend.friendId).emit("userStatus", {
userId: user.id,
status: "online"
})
})
io.to(user.id).emit("userStatus", {
userId: user.id,
status: "online"
})
await user.update({
status: "online"
})
}
})
socket.on("disconnect", async function () {
friends.forEach((friend) => {
io.to(friend.friendId).emit("userStatus", {
userId: user.id,
status: "offline"
})
})
await user.update({
status: "offline"
})
})
})
console.log("WS OK")
app.set("io", io)
}
}

View file

@ -0,0 +1,29 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("Users", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
username: {
allowNull: false,
type: Sequelize.STRING,
unique: true
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("Users")
}
}

View file

@ -0,0 +1,39 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("Sessions", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
session: {
type: Sequelize.STRING
},
compassUserId: {
type: Sequelize.BIGINT
},
sussiId: {
type: Sequelize.STRING
},
other: {
type: Sequelize.JSON
},
instance: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("Sessions")
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "theme", {
type: Sequelize.STRING,
allowNull: false,
defaultValue: "dark"
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,18 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Sessions", "expiredAt", {
type: Sequelize.DATE
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,93 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "themeId", {
type: Sequelize.BIGINT,
defaultValue: 1
})
await queryInterface.createTable("Themes", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
name: {
type: Sequelize.STRING,
defaultValue: "A Colubrina Theme"
},
userId: {
type: Sequelize.BIGINT
},
public: {
type: Sequelize.BOOLEAN,
defaultValue: false
},
theme: {
type: Sequelize.JSON,
defaultValue: {
name: "A Colubrina Theme",
primaryType: "all",
dark: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
nav: "#FFFFFF",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
},
light: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
nav: "#FFFFFF",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
}
}
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "accentColor", {
type: Sequelize.STRING,
defaultValue: null,
allowNull: true
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "guidedWizard", {
type: Sequelize.BOOLEAN,
defaultValue: true
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,230 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("Chats", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
type: {
type: Sequelize.ENUM(["direct", "group", "channel"])
},
privacy: {
type: Sequelize.ENUM([
"direct",
"everyoneInvited",
"tenantInvited",
"manualInvited"
])
},
name: {
type: Sequelize.STRING,
defaultValue: "Unnamed Group",
allowNull: false
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
usersId: {
type: Sequelize.JSON,
defaultValue: [],
allowNull: false
},
icon: {
type: Sequelize.STRING,
defaultValue: null
},
privilegedUserIds: {
type: Sequelize.JSON,
defaultValue: [],
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
await queryInterface.createTable("Messages", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
chatId: {
type: Sequelize.BIGINT,
allowNull: false
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
content: {
type: Sequelize.TEXT,
allowNull: false
},
type: {
type: Sequelize.ENUM([
"message",
"leave",
"join",
"pin",
"administrator",
"rename",
"system"
])
},
embeds: {
type: Sequelize.JSON,
defaultValue: [],
allowNull: false
},
attachments: {
type: Sequelize.JSON,
defaultValue: [],
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
await queryInterface.createTable("Invites", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
invite: {
type: Sequelize.STRING,
allowNull: false
},
chatId: {
type: Sequelize.BIGINT,
allowNull: false
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
expiresAt: {
type: Sequelize.DATE,
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
await queryInterface.createTable("BlockedUsers", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
blockedUserId: {
type: Sequelize.BIGINT,
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
await queryInterface.createTable("MutedChats", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
chatId: {
type: Sequelize.BIGINT,
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
await queryInterface.addColumn("users", "privacy", {
type: Sequelize.JSON,
defaultValue: {
communications: {
enabled: false,
outsideTenant: false,
directMessages: "friendsOnly",
friendRequests: true
}
},
allowNull: false
})
await queryInterface.createTable("friends", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
friendId: {
type: Sequelize.BIGINT,
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "name", {
type: Sequelize.STRING,
allowNull: false
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,44 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("ChatAssociations", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.BIGINT
},
chatId: {
type: Sequelize.BIGINT,
allowNull: false
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
rank: {
type: Sequelize.ENUM(["member", "admin"]),
defaultValue: "member",
allowNull: false
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "admin", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,38 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "totp", {
type: Sequelize.TEXT,
allowNull: true
})
await queryInterface.addColumn("Users", "totpEnabled", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
})
await queryInterface.addColumn("Users", "emailDirectLogin", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
})
await queryInterface.addColumn("Users", "email", {
type: Sequelize.STRING,
allowNull: true
})
await queryInterface.addColumn("Users", "bcSessions", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Sessions", "userId", {
type: Sequelize.BIGINT,
allowNull: false
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "lastSeenAt", {
type: Sequelize.DATE,
allowNull: true
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "password", {
type: Sequelize.TEXT,
allowNull: true,
defaultValue: null
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "font", {
type: Sequelize.STRING,
defaultValue: "Roboto",
allowNull: false
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "status", {
type: Sequelize.ENUM(["online", "busy", "away", "offline", "invisible"]),
allowNull: false,
defaultValue: "offline"
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "storedStatus", {
type: Sequelize.ENUM(["online", "busy", "away", "invisible"]),
allowNull: false,
defaultValue: "online"
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("friends", "status", {
type: Sequelize.ENUM(["pending", "accepted", "declined"]),
allowNull: false,
defaultValue: "pending"
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,24 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
// modify status column
await queryInterface.changeColumn("friends", "status", {
type: Sequelize.ENUM([
"pending",
"pendingCanAccept",
"accepted",
"rejected"
])
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,20 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Users", "experiments", {
type: Sequelize.JSON,
allowNull: false,
defaultValue: []
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("chatAssociations", "lastRead", {
type: Sequelize.BIGINT,
allowNull: true
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,24 @@
"use strict"
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("Messages", "edited", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
})
await queryInterface.addColumn("Messages", "editedAt", {
type: Sequelize.DATE,
allowNull: true
})
},
down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,54 @@
"use strict"
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable("Attachments", {
id: {
type: Sequelize.BIGINT,
primaryKey: true,
autoIncrement: true
},
name: {
type: Sequelize.STRING,
allowNull: false
},
attachment: {
type: Sequelize.STRING,
allowNull: false
},
type: {
type: Sequelize.ENUM(["message", "avatar"]),
allowNull: false,
defaultValue: "message"
},
size: {
type: Sequelize.BIGINT,
allowNull: false
},
extension: {
type: Sequelize.STRING,
allowNull: true
},
userId: {
type: Sequelize.BIGINT,
allowNull: false
},
chatId: {
type: Sequelize.BIGINT,
allowNull: true
},
createdAt: {
type: Sequelize.DATE,
allowNull: false
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false
}
})
},
async down(queryInterface, Sequelize) {
await queryInterface.dropTable("Attachments")
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn("Users", "avatar", {
type: Sequelize.STRING,
allowNull: true
})
},
async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn("messages", "replyId", {
type: Sequelize.BIGINT,
defaultValue: null
})
},
async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,19 @@
"use strict"
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn("Attachments", "messageId", {
type: Sequelize.BIGINT
})
await queryInterface.removeColumn("Messages", "attachments")
},
async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
}

View file

@ -0,0 +1,72 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Attachment extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
Attachment.belongsTo(models.User, {
foreignKey: "userId",
as: "user"
})
Attachment.belongsTo(models.Chat, {
foreignKey: "chatId",
as: "chat"
})
}
}
Attachment.init(
{
name: {
type: DataTypes.STRING,
allowNull: false
},
attachment: {
type: DataTypes.STRING,
allowNull: false
},
type: {
type: DataTypes.ENUM(["message", "avatar"]),
allowNull: false,
defaultValue: "message"
},
size: {
type: DataTypes.BIGINT,
allowNull: false
},
extension: {
type: DataTypes.STRING,
allowNull: true
},
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
chatId: {
type: DataTypes.BIGINT,
allowNull: true
},
messageId: {
type: DataTypes.BIGINT,
allowNull: true
},
createdAt: {
type: DataTypes.DATE,
allowNull: false
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false
}
},
{
sequelize,
modelName: "Attachment"
}
)
return Attachment
}

View file

@ -0,0 +1,40 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class BlockedUser extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
// define association here
}
}
BlockedUser.init(
{
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
blockedUserId: {
type: DataTypes.BIGINT,
allowNull: false
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
},
{
sequelize,
modelName: "BlockedUser"
}
)
return BlockedUser
}

View file

@ -0,0 +1,56 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class ChatAssociation extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
ChatAssociation.belongsTo(models.User, {
foreignKey: "userId",
as: "user"
})
ChatAssociation.belongsTo(models.Chat, {
foreignKey: "chatId",
as: "chat"
})
}
}
ChatAssociation.init(
{
chatId: {
type: DataTypes.BIGINT,
allowNull: false
},
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
rank: {
type: DataTypes.ENUM(["member", "admin"]),
defaultValue: "member",
allowNull: false
},
lastRead: {
type: DataTypes.BIGINT,
defaultValue: null
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
},
{
sequelize,
modelName: "ChatAssociation"
}
)
return ChatAssociation
}

82
backend/models/chats.js Normal file
View file

@ -0,0 +1,82 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Chat extends Model {
/**
* Helper method for defining associations.
* This method is not a part of DataTypes lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
Chat.belongsTo(models.User, {
foreignKey: "userId",
as: "user"
})
Chat.hasMany(models.ChatAssociation, {
foreignKey: "chatId",
as: "associations"
})
Chat.belongsToMany(models.User, {
through: "chatAssociations",
as: "users",
foreignKey: "chatId"
})
Chat.hasMany(models.Message, {
foreignKey: "chatId",
as: "lastMessages"
})
}
}
Chat.init(
{
type: {
type: DataTypes.ENUM(["direct", "group", "channel"])
},
privacy: {
type: DataTypes.ENUM([
"direct",
"everyoneInvited",
"tenantInvited",
"manualInvited"
])
},
name: {
type: DataTypes.STRING,
defaultValue: "Unnamed Group",
allowNull: false
},
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
usersId: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: false
},
icon: {
type: DataTypes.STRING,
defaultValue: null
},
privilegedUserIds: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: false
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
},
{
sequelize,
modelName: "Chat"
}
)
return Chat
}

View file

@ -0,0 +1,33 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Feedback extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
Feedback.belongsTo(models.User, {
foreignKey: "userId",
as: "user"
})
}
}
Feedback.init(
{
feedbackText: DataTypes.TEXT,
starRating: DataTypes.BIGINT,
route: DataTypes.STRING,
userId: DataTypes.STRING,
tenant: DataTypes.STRING,
debug: DataTypes.JSON
},
{
sequelize,
modelName: "Feedback"
}
)
return Feedback
}

39
backend/models/friends.js Normal file
View file

@ -0,0 +1,39 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Friend extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
Friend.belongsTo(models.User, {
foreignKey: "userId",
as: "user"
})
Friend.belongsTo(models.User, {
foreignKey: "friendId",
as: "user2"
})
}
}
Friend.init(
{
userId: DataTypes.BIGINT,
friendId: DataTypes.BIGINT,
status: {
type: DataTypes.ENUM(["pending", "accepted", "declined"]),
defaultValue: "pending"
},
createdAt: DataTypes.DATE,
updatedAt: DataTypes.DATE
},
{
sequelize,
modelName: "Friend"
}
)
return Friend
}

46
backend/models/index.js Normal file
View file

@ -0,0 +1,46 @@
"use strict"
const fs = require("fs")
const path = require("path")
const Sequelize = require("sequelize")
const basename = path.basename(__filename)
const env = process.env.NODE_ENV || "development"
const config = require(__dirname + "/../config/config.json")[env]
const db = {}
let sequelize
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config)
} else {
sequelize = new Sequelize(
config.database,
config.username,
config.password,
config
)
}
fs.readdirSync(__dirname)
.filter((file) => {
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
)
})
.forEach((file) => {
const model = require(path.join(__dirname, file))(
sequelize,
Sequelize.DataTypes
)
db[model.name] = model
})
Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db)
}
})
db.sequelize = sequelize
db.Sequelize = Sequelize
module.exports = db

48
backend/models/invites.js Normal file
View file

@ -0,0 +1,48 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Invite extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
// define association here
}
}
Invite.init(
{
invite: {
type: DataTypes.STRING,
allowNull: false
},
chatId: {
type: DataTypes.BIGINT,
allowNull: false
},
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
expiresAt: {
type: DataTypes.DATE,
allowNull: false
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
},
{
sequelize,
modelName: "Invite"
}
)
return Invite
}

View file

@ -0,0 +1,85 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Message extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
Message.belongsTo(models.User, {
as: "user"
})
Message.belongsTo(models.Chat, {
as: "chat"
})
Message.belongsTo(models.Message, {
as: "reply"
})
Message.hasMany(models.Attachment, {
as: "attachments",
foreignKey: "messageId"
})
}
}
Message.init(
{
chatId: {
type: DataTypes.BIGINT,
allowNull: false
},
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
content: {
type: DataTypes.TEXT,
allowNull: false
},
type: {
type: DataTypes.ENUM([
"message",
"leave",
"join",
"pin",
"administrator",
"rename",
"system"
])
},
embeds: {
type: DataTypes.JSON,
defaultValue: [],
allowNull: false
},
edited: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
},
editedAt: {
type: DataTypes.DATE,
allowNull: true
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
},
replyId: {
type: DataTypes.BIGINT,
allowNull: true
}
},
{
sequelize,
modelName: "Message"
}
)
return Message
}

View file

@ -0,0 +1,40 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class MutedChat extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// eslint-disable-next-line no-unused-vars
static associate(models) {
// define association here
}
}
MutedChat.init(
{
userId: {
type: DataTypes.BIGINT,
allowNull: false
},
chatId: {
type: DataTypes.BIGINT,
allowNull: false
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
},
{
sequelize,
modelName: "MutedChat"
}
)
return MutedChat
}

View file

@ -0,0 +1,30 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Session extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
}
Session.init(
{
session: DataTypes.STRING,
compassUserId: DataTypes.BIGINT,
sussiId: DataTypes.STRING,
other: DataTypes.JSON,
instance: DataTypes.STRING,
userId: DataTypes.BIGINT,
expiredAt: DataTypes.DATE
},
{
sequelize,
modelName: "Session"
}
)
return Session
}

87
backend/models/themes.js Normal file
View file

@ -0,0 +1,87 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class Theme extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
Theme.belongsTo(models.User, {
as: "user"
})
Theme.hasMany(models.User, {
as: "users"
})
}
}
Theme.init(
{
name: {
type: DataTypes.STRING,
defaultValue: "A Colubrina Theme"
},
userId: {
type: DataTypes.BIGINT
},
public: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
theme: {
type: DataTypes.JSON,
defaultValue: {
name: "A Colubrina Theme",
primaryType: "all",
dark: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
nav: "#FFFFFF",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
},
light: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
nav: "#FFFFFF",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
}
}
}
},
{
sequelize,
modelName: "Theme"
}
)
return Theme
}

146
backend/models/users.js Normal file
View file

@ -0,0 +1,146 @@
"use strict"
const { Model } = require("sequelize")
module.exports = (sequelize, DataTypes) => {
class User extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
User.belongsTo(models.Theme, {
as: "themeObject",
foreignKey: "themeId"
})
User.hasMany(models.Friend, {
as: "friends",
foreignKey: "userId"
})
}
}
User.init(
{
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
notNull: {
msg: "Username is required"
},
notEmpty: {
msg: "Username is required"
},
len: {
args: [2, 12],
msg: "Username must be between 2 and 12 characters"
},
regex: {
args: /^[a-z0-9_-]+$/i,
msg: "Username must be alphanumeric"
}
}
},
theme: {
type: DataTypes.STRING,
defaultValue: "dark"
},
themeId: {
type: DataTypes.BIGINT,
allowNull: false,
defaultValue: 1
},
accentColor: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null
},
guidedWizard: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true
},
privacy: {
type: DataTypes.JSON,
defaultValue: {
communications: {
enabled: true,
outsideTenant: false,
directMessages: "friendsOnly",
friendRequests: true
}
}
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: ""
},
admin: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
totp: {
type: DataTypes.TEXT,
allowNull: true
},
totpEnabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
emailDirectLogin: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
email: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isEmail: true
}
},
password: {
type: DataTypes.TEXT,
allowNull: true
},
font: {
type: DataTypes.STRING,
defaultValue: "Roboto",
allowNull: false
},
status: {
type: DataTypes.ENUM([
"online",
"busy",
"away",
"offline",
"invisible"
]),
allowNull: false,
defaultValue: "offline"
},
storedStatus: {
type: DataTypes.ENUM(["online", "busy", "away", "invisible"]),
allowNull: false,
defaultValue: "online"
},
experiments: {
type: DataTypes.JSON,
allowNull: false,
defaultValue: []
},
avatar: {
type: DataTypes.STRING,
allowNull: true
}
},
{
sequelize,
modelName: "User"
}
)
return User
}

60
backend/nginx.conf Normal file
View file

@ -0,0 +1,60 @@
location /Services {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /services {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /download {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /Assets {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /graphql {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /socket.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location /usercontent {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_pass http://localhost:23994;
}
location / {
try_files $uri $uri/ /index.html;
}
client_max_body_size 100M;

43
backend/package.json Normal file
View file

@ -0,0 +1,43 @@
{
"name": "colubrina-backend",
"version": "1.0.0",
"private": true,
"license": "GPL-3.0",
"scripts": {
"start": "node .",
"serve": "nodemon"
},
"dependencies": {
"argon2": "^0.28.5",
"axios": "^0.26.1",
"clean-css": "^4.1.11",
"constantinople": "3.1.1",
"cookie-parser": "^1.4.6",
"crypto-random-string": "3.3.1",
"debug": "~2.6.9",
"dotenv": "^16.0.0",
"express": "^4.17.1",
"express-rate-limit": "^6.4.0",
"file-type": "16.5.3",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"jw-paginate": "^1.0.4",
"local-cors-proxy": "^1.1.0",
"mariadb": "^3.0.0",
"multer": "^1.4.4",
"node-xwhois": "^2.0.10",
"open-graph-scraper": "^4.11.0",
"patch-package": "^6.4.7",
"semver": "^7.3.7",
"sequelize": "^6.17.0",
"socket.io": "^4.5.1",
"speakeasy": "^2.0.0",
"ua-parser-js": "^1.0.2",
"uglify-js": "^2.6.0"
},
"resolutions": {
"constantinople": "^3.1.1",
"clean-css": "^4.1.11",
"uglify-js": "^2.6.0"
}
}

253
backend/routes/admin.js Normal file
View file

@ -0,0 +1,253 @@
const express = require("express")
const router = express.Router()
const Errors = require("../lib/errors.js")
const auth = require("../lib/authorize.js")
const { User, Theme, Feedback, Message } = require("../models")
const { Op } = require("sequelize")
const dayjs = require("dayjs")
const fs = require("fs")
const os = require("os")
router.all("*", auth, async (req, res, next) => {
try {
if (!req.user.admin) {
throw Errors.unauthorized
} else {
next()
}
} catch (err) {
next(err)
}
})
router.get("/", auth, async (req, res, next) => {
try {
res.json({
users: await User.count(),
themes: await Theme.count(),
feedback: await Feedback.count(),
messages: await Message.count(),
usersToday: await User.count({
where: {
lastSeenAt: {
[Op.gte]: dayjs().startOf("day").toDate()
}
}
}),
usersThisWeek: await User.count({
where: {
lastSeenAt: {
[Op.gte]: dayjs().startOf("week").toDate()
}
}
})
})
} catch (err) {
return next(err)
}
})
router.get("/metrics", auth, async (req, res, next) => {
try {
const sevenDaysAgo = new Date(new Date().setDate(new Date().getDate() - 7))
const createdAt = {
[Op.gte]: sevenDaysAgo
}
const registrationStats = await User.findAll({
where: {
createdAt: createdAt
},
attributes: {
exclude: ["totp", "compassSession", "password"]
}
})
const registrationGraphInterim = registrationStats.reduce(function (
result,
user
) {
let day = dayjs(user.createdAt).format("YYYY-MM-DD")
if (!result[day]) {
result[day] = 0
}
result[day]++
return result
},
{})
const activeUsersGraphInterim = registrationStats.reduce(function (
result,
user
) {
let day = dayjs(user.lastSeenAt).format("YYYY-MM-DD")
if (!result[day]) {
result[day] = 0
}
result[day]++
return result
},
{})
const usersGraph = {
labels: Object.keys(registrationGraphInterim),
datasets: [
{
data: Object.values(registrationGraphInterim),
label: "Users",
borderColor: "#3e95cd",
pointBackgroundColor: "#FFFFFF",
backgroundColor: "transparent"
}
]
}
const activeUsersGraph = {
labels: Object.keys(activeUsersGraphInterim),
datasets: [
{
data: Object.values(activeUsersGraphInterim),
label: "Active Users",
borderColor: "#3e95cd",
pointBackgroundColor: "#FFFFFF",
backgroundColor: "transparent"
}
]
}
res.json({
users: usersGraph,
activeUsers: activeUsersGraph
})
} catch (err) {
return next(err)
}
})
router.get("/users", auth, async (req, res, next) => {
try {
const users = await User.findAndCountAll({
include: [
{
model: Theme,
as: "themeObject"
}
],
attributes: {
exclude: ["totp", "compassSession", "password"]
}
})
res.json(users)
} catch (err) {
return next(err)
}
})
router.get("/themes", auth, async (req, res, next) => {
try {
const themes = await Theme.findAndCountAll({
include: [
{
model: User,
as: "user",
attributes: {
exclude: ["totp", "compassSession", "password"]
}
},
{
model: User,
as: "users"
}
]
})
res.json(themes)
} catch (err) {
return next(err)
}
})
router.put("/themes/apply", auth, async (req, res, next) => {
try {
await User.update(
{
themeId: req.body.themeId
},
{
where: {
id: req.user.id
}
}
)
res.sendStatus(204)
} catch (err) {
return next(err)
}
})
router.get("/feedback", auth, async (req, res, next) => {
try {
const feedback = await Feedback.findAndCountAll({
order: [["createdAt", "DESC"]],
include: [
{
model: User,
as: "user"
}
]
})
res.json(feedback)
} catch (err) {
return next(err)
}
})
router.put("/state", auth, async (req, res, next) => {
function setEnvValue(key, value) {
// read file from hdd & split if from a linebreak to a array
const ENV_VARS = fs.readFileSync(".env", "utf8").split(os.EOL)
// find the env we want based on the key
const target = ENV_VARS.indexOf(
ENV_VARS.find((line) => {
// (?<!#\s*) Negative lookbehind to avoid matching comments (lines that starts with #).
// There is a double slash in the RegExp constructor to escape it.
// (?==) Positive lookahead to check if there is an equal sign right after the key.
// This is to prevent matching keys prefixed with the key of the env var to update.
const keyValRegex = new RegExp(`(?<!#\\s*)${key}(?==)`)
return line.match(keyValRegex)
})
)
// if key-value pair exists in the .env file,
if (target !== -1) {
// replace the key/value with the new value
ENV_VARS.splice(target, 1, `${key}=${value}`)
} else {
// if it doesn't exist, add it instead
ENV_VARS.push(`${key}=${value}`)
}
// write everything back to the file system
fs.writeFileSync(".env", ENV_VARS.join(os.EOL))
}
try {
const io = req.app.get("io")
if (req.body.broadcastType === "permanent") {
setEnvValue("NOTIFICATION", req.body.notification)
setEnvValue("NOTIFICATION_TYPE", req.body.notificationType)
process.env.NOTIFICATION = req.body.notification
process.env.NOTIFICATION_TYPE = req.body.notificationType
}
io.emit("siteState", {
notification: req.body.notification,
notificationType: req.body.notificationType,
latestVersion: require("../../package.json").version
})
res.sendStatus(204)
} catch (err) {
return next(err)
}
})
module.exports = router

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
const express = require("express")
const router = express.Router()
const Errors = require("../lib/errors.js")
const { Message } = require("../models")
const axios = require("axios")
router.get("/:mid/:index/:securityToken", async (req, res, next) => {
try {
const message = await Message.findOne({
where: {
id: req.params.mid
}
})
if (!message) {
throw Errors.invalidParameter("message id")
}
const embed = message.embeds.find(
(e) => e.securityToken === req.params.securityToken
)
if (!embed) {
throw Errors.invalidParameter("securityToken")
}
await axios
.get(embed.link, {
headers: {
"user-agent": "Googlebot/2.1 (+http://www.google.com/bot.html)"
},
responseType: "arraybuffer"
})
.then((response) => {
res.setHeader("content-type", response.headers["content-type"])
res.setHeader("cache-control", "public, max-age=604800")
res.end(response.data, "binary")
})
} catch (e) {
next(e)
}
})
router.get("/:mid/:index/:securityToken.:extension", async (req, res, next) => {
try {
const message = await Message.findOne({
where: {
id: req.params.mid
}
})
if (!message) {
throw Errors.invalidParameter("message id")
}
const embed = message.embeds.find(
(e) => e.securityToken === req.params.securityToken
)
if (!embed) {
throw Errors.invalidParameter("securityToken")
}
await axios
.get(embed.link, {
headers: {
"user-agent": "Googlebot/2.1 (+http://www.google.com/bot.html)"
},
responseType: "arraybuffer"
})
.then((response) => {
res.setHeader("content-type", response.headers["content-type"])
res.setHeader("cache-control", "public, max-age=604800")
res.end(response.data, "binary")
})
} catch (e) {
next(e)
}
})
module.exports = router

121
backend/routes/theme.js Normal file
View file

@ -0,0 +1,121 @@
const express = require("express")
const router = express.Router()
const Errors = require("../lib/errors.js")
const auth = require("../lib/authorize.js")
const { User, Theme } = require("../models")
const { Op } = require("sequelize")
router.get("/", auth, async (req, res, next) => {
try {
const themes = await Theme.findAll({
where: {
[Op.or]: [
{
userId: req.user.id
},
{
public: true
}
]
},
include: [
{
model: User,
attributes: ["id", "username"],
as: "user"
}
]
})
res.json(themes)
} catch (e) {
next(e)
}
})
router.post("/", auth, async (req, res, next) => {
try {
if (
!req.body.theme?.name ||
!req.body.theme?.primaryType ||
!req.body.theme?.dark ||
!req.body.theme?.light
) {
throw Errors.invalidParameter("theme", "Theme validation failed.")
}
const theme = await Theme.create({
name: req.body.name,
public: false,
userId: req.user.id,
theme: req.body.theme
})
res.json(theme)
} catch (e) {
next(e)
}
})
router.put("/:id", auth, async (req, res, next) => {
try {
if (
!req.body.theme?.name ||
!req.body.theme?.primaryType ||
!req.body.theme?.dark ||
!req.body.theme?.light
) {
throw Errors.invalidParameter("theme", "Theme validation failed.")
}
const theme = await Theme.findOne({
where: {
id: req.params.id,
userId: req.user.id
}
})
if (!theme) {
throw Errors.invalidParameter("theme", "Theme not found.")
}
await theme.update({
name: req.body.name,
theme: req.body.theme
})
res.json(theme)
} catch (e) {
next(e)
}
})
router.delete("/:id", auth, async (req, res, next) => {
try {
const theme = await Theme.findOne({
where: {
id: req.params.id,
userId: req.user.id
}
})
if (!theme) {
throw Errors.invalidParameter("theme", "Theme not found.")
}
await User.update(
{
themeId: 1
},
{
where: {
themeId: theme.id
}
}
)
await theme.destroy()
res.sendStatus(204)
} catch (e) {
next(e)
}
})
module.exports = router

604
backend/routes/user.js Normal file
View file

@ -0,0 +1,604 @@
const express = require("express")
const router = express.Router()
const Errors = require("../lib/errors.js")
const auth = require("../lib/authorize.js")
const axios = require("axios")
const { User, Session, Theme, Friend, Attachment } = require("../models")
const cryptoRandomString = require("crypto-random-string")
const { Op } = require("sequelize")
const speakeasy = require("speakeasy")
const argon2 = require("argon2")
const UAParser = require("ua-parser-js")
const fs = require("fs")
const path = require("path")
const semver = require("semver")
const multer = require("multer")
const FileType = require("file-type")
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "usercontent/")
},
filename: function (req, file, cb) {
cb(
null,
cryptoRandomString({ length: 32 }) + path.extname(file.originalname)
)
}
})
const whitelist = [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"image/gif"
]
const upload = multer({
storage: storage,
limits: { fileSize: 2 * 1024 * 1024 },
fileFilter: (req, file, cb) => {
if (!whitelist.includes(file.mimetype)) {
return cb(new Error("Only images are allowed"))
}
cb(null, true)
}
})
router.post("/login", async (req, res, next) => {
async function checkPassword(password, hash) {
try {
return await argon2.verify(hash, password)
} catch {
console.log("Error")
return false
}
}
async function generateSession(user) {
try {
const ua = UAParser(req.headers["user-agent"])
let ip = {}
await axios
.get("http://ip-api.com/json/ " + req.header("x-real-ip") || req.ip)
.then((res) => {
ip = res.data
})
.catch(() => {})
const session = await Session.create({
userId: user.id,
instance: req.body.instance || "",
session: "COLUBRINA-" + cryptoRandomString({ length: 128 }),
compassUserId: user.compassUserId,
sussiId: user.sussiId,
expiredAt: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 30),
compassSession: user.compassSession,
other: {
ip: req.header("x-real-ip") || req.ip,
location: ip.country
? `${ip.city} - ${ip.regionName} - ${ip.country}`
: null,
isp: ip.isp,
asn: ip.as,
browserString: ua.browser.name + " v" + ua.browser.major,
osString: ua.os.name + " " + ua.os.version,
browser: ua.browser.name,
browserVersion: ua.browser.version,
browserVersionMajor: ua.browser.major,
os: ua.os.name,
osVersion: ua.os.version
}
})
res.cookie("session", session.session, {
maxAge: 1000 * 60 * 60 * 24 * 365,
httpOnly: true,
secure: true,
sameSite: "strict"
})
res.json({
session: session.session,
success: true,
userId: user.id
})
} catch (e) {
console.log(e)
return false
}
}
try {
const user = await User.findOne({
where: {
username: req.body.username || ""
}
})
if (user) {
if (await checkPassword(req.body.password, user.password)) {
if (user.totpEnabled) {
const verified = speakeasy.totp.verify({
secret: user.totp,
encoding: "base32",
token: req.body.totp || ""
})
if (verified) {
await generateSession(user)
} else {
throw Errors.invalidTotp
}
} else {
await generateSession(user)
}
} else {
throw Errors.invalidCredentials
}
} else {
throw Errors.invalidCredentials
}
} catch (err) {
next(err)
}
})
router.post("/register", async (req, res, next) => {
async function generatePassword(password) {
try {
return await argon2.hash(password)
} catch {
console.log("Error")
return false
}
}
async function generateSession(user) {
try {
const ua = UAParser(req.headers["user-agent"])
let ip = {}
await axios
.get("http://ip-api.com/json/ " + req.header("x-real-ip") || req.ip)
.then((res) => {
ip = res.data
})
.catch(() => {})
const session = await Session.create({
userId: user.id,
instance: req.body.instance || "",
session: "COLUBRINA-" + cryptoRandomString({ length: 128 }),
compassUserId: user.compassUserId,
sussiId: user.sussiId,
expiredAt: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 30),
compassSession: user.compassSession,
other: {
ip: req.header("x-real-ip") || req.ip,
location: ip.country
? `${ip.city} - ${ip.regionName} - ${ip.country}`
: null,
isp: ip.isp,
asn: ip.as,
browserString: ua.browser.name + " v" + ua.browser.major,
osString: ua.os.name + " " + ua.os.version,
browser: ua.browser.name,
browserVersion: ua.browser.version,
browserVersionMajor: ua.browser.major,
os: ua.os.name,
osVersion: ua.os.version
}
})
res.cookie("session", session.session, {
maxAge: 1000 * 60 * 60 * 24 * 365,
httpOnly: true,
secure: true,
sameSite: "strict"
})
res.json({
session: session.session,
success: true,
userId: user.id
})
} catch (e) {
console.log(e)
return false
}
}
try {
if (req.body.password.length < 8) {
throw Errors.invalidPassword
}
const user = await User.create({
username: req.body.username,
password: await generatePassword(req.body.password),
theme: "dark",
themeId: 1,
guidedWizard: true,
name: req.body.username,
admin: false,
email: req.body.email,
font: "Roboto",
status: "offline",
storedStatus: "online",
experiments: [],
avatar: null
})
if (user) {
await generateSession(user)
} else {
throw Errors.unknown
}
} catch (err) {
next(err)
}
})
router.get("/", auth, (req, res, next) => {
try {
res.json(req.user)
} catch (e) {
console.log(1)
}
})
router.get("/sessions", auth, async (req, res, next) => {
try {
const sessions = await Session.findAll({
where: {
userId: req.user.id
},
attributes: {
exclude: ["session"]
}
})
res.json(sessions)
} catch (e) {
next(e)
}
})
router.delete("/sessions/:id", auth, async (req, res, next) => {
try {
await Session.destroy({
where: {
id: req.params.id,
userId: req.user.id
}
})
res.sendStatus(204)
} catch (e) {
next(e)
}
})
router.post("/logout", (req, res, next) => {
try {
res.clearCookie("session")
res.sendStatus(204)
} catch (e) {
next(e)
}
})
router.post(
"/settings/avatar",
auth,
upload.single("avatar"),
async (req, res, next) => {
try {
const io = req.app.get("io")
if (req.file) {
const meta = await FileType.fromFile(req.file.path)
if (!whitelist.includes(meta.mime)) {
throw Errors.invalidFileType
}
const attachment = await Attachment.create({
userId: req.user.id,
type: "avatar",
attachment: req.file.filename,
name: req.file.originalname,
extension: meta.ext,
size: req.file.size
})
await User.update(
{
avatar: attachment.attachment
},
{
where: {
id: req.user.id
}
}
)
res.json(attachment)
const friends = await Friend.findAll({
where: {
userId: req.user.id
}
})
io.to(req.user.id).emit("userSettings", {
userId: req.user.id,
avatar: attachment.attachment,
status: req.body.status === "invisible" ? "offline" : req.body.status,
storedStatus: req.body.status
})
friends.forEach((friend) => {
io.to(friend.id).emit("userSettings", {
userId: req.user.id,
avatar: attachment.attachment,
status:
req.body.status === "invisible" ? "offline" : req.body.status,
storedStatus: req.body.status
})
})
} else {
throw Errors.invalidParameter("avatar")
}
} catch (e) {
next(e)
}
}
)
router.put("/settings/:type", auth, async (req, res, next) => {
async function checkPasswordArgon2(password, hash) {
try {
return await argon2.verify(hash, password)
} catch {
console.log("Error")
return false
}
}
async function checkPassword(password) {
return new Promise((resolve, reject) => {
axios
.post(
"http://localhost:23994/services/admin.svc/GetApiKey",
{
password: password,
schoolId: req.body.schoolId,
sussiId: req.user.sussiId
},
{
headers: {
compassInstance:
req.header("compassInstance") ||
req.query.compassInstance ||
"devices"
}
}
)
.then((resp) => {
if (resp.data.d) {
resolve(true)
return true
} else {
resolve(false)
return false
}
})
.catch((e) => {
reject(e)
return false
})
})
}
try {
const io = req.app.get("io")
if (req.params.type === "full") {
await User.update(
{
theme: req.body.theme,
guidedWizard: req.body.guidedWizard,
font: req.body.font,
experiments: req.body.experiments,
username: req.body.username,
email: req.body.email
},
{
where: {
id: req.user.id
}
}
)
res.sendStatus(204)
} else if (req.params.type === "theme") {
const theme = await Theme.findOne({
where: {
id: req.body.id,
[Op.or]: [
{
userId: req.user.id
},
{
public: true
}
]
}
})
if (theme) {
await User.update(
{
themeId: theme.id,
accentColor: req.body.accent
},
{
where: {
id: req.user.id
}
}
)
res.sendStatus(204)
} else {
throw Errors.invalidParameter("Theme", "Invalid theme specified")
}
} else if (req.params.type === "totp") {
if (req.user.totpEnabled && req.body.code) {
res.json({ enabled: true })
} else if (!req.user.totpEnabled && req.body.password) {
const match = await checkPassword(req.body.password)
if (match) {
const token = speakeasy.generateSecret({
name: "Colubrina - " + req.user.username,
issuer: "Colubrina"
})
await User.update(
{
totp: token.base32
},
{
where: {
id: req.user.id
}
}
)
res.json({ secret: token.base32, enabled: false })
} else {
throw Errors.invalidCredentials
}
} else {
throw Errors.invalidParameter("Password or Code")
}
} else if (req.params.type === "totpConfirm") {
const user = await User.findOne({
where: {
id: req.user.id
}
})
if (user.totp) {
const verified = speakeasy.totp.verify({
secret: user.totp,
encoding: "base32",
token: req.body.code
})
if (verified) {
await User.update(
{
totpEnabled: true
},
{
where: {
id: req.user.id
}
}
)
res.sendStatus(204)
} else {
throw Errors.invalidTotp
}
} else {
throw Errors.unknown
}
} else if (req.params.type === "bcSessionsEnable") {
/*
const match = await checkPassword(req.body.password)
if (match) {
await User.update(
{
bcSessionsEnabled: true
},
{
where: {
id: req.user.id
}
}
)
const session = await Session.create({
session:
"BETTERCOMPASS-" +
cryptoRandomString({
length: 64
}),
compassUserId: req.user.compassUserId,
sussiId: req.user.sussiId,
instance: req.user.instance,
other: {},
userId: req.user.id
})
} else {
throw Errors.invalidCredentials
}*/
throw Errors.experimentsOptIn
} else if (req.params.type === "password") {
const user = await User.findOne({
where: {
id: req.user.id
}
})
let match
if (user.password) {
match = await checkPasswordArgon2(req.body.password)
} else {
match = true
}
if (match) {
await user.update({
password: await argon2.hash(req.body.new)
})
res.sendStatus(204)
} else {
throw Errors.invalidCredentials
}
} else if (req.params.type === "communications") {
const user = await User.findOne({
where: {
id: req.user.id
}
})
await user.update({
privacy: {
communications: {
enabled: req.body.enabled,
outsideTenant: req.body.outsideTenant,
directMessages: req.body.directMessages,
friendRequests: req.body.friendRequests
}
}
})
res.sendStatus(204)
} else if (req.params.type === "status") {
const user = await User.findOne({
where: {
id: req.user.id
}
})
if (!["online", "away", "busy", "invisible"].includes(req.body.status)) {
res.json({
status: user.status,
storedStatus: user.storedStatus
})
} else {
await user.update({
storedStatus: req.body.status,
status: req.body.status === "invisible" ? "offline" : req.body.status
})
const friends = await Friend.findAll({
where: {
userId: user.id,
status: "accepted"
}
})
friends.forEach((friend) => {
io.to(friend.friendId).emit("userStatus", {
userId: user.id,
status:
req.body.status === "invisible" ? "offline" : req.body.status
})
})
io.to(user.id).emit("userStatus", {
userId: user.id,
status: req.body.status === "invisible" ? "offline" : req.body.status
})
io.to(user.id).emit("userSettings", {
userId: user.id,
status: req.body.status === "invisible" ? "offline" : req.body.status,
storedStatus: req.body.status
})
res.json({
status: req.body.status === "invisible" ? "offline" : req.body.status,
storedStatus: req.body.status
})
}
} else {
throw Errors.invalidParameter("Settings type", "Invalid settings type")
}
} catch (e) {
console.log(e)
next(e)
}
})
module.exports = router

View file

@ -0,0 +1,35 @@
const express = require("express")
const router = express.Router()
const Errors = require("../lib/errors.js")
const { Attachment } = require("../models")
const path = require("path")
router.get("/:attachment", async (req, res, next) => {
try {
const attachment = await Attachment.findOne({
where: {
attachment: req.params.attachment
}
})
if (!attachment) {
throw Errors.attachmentNotFound
} else {
if (
[".jpg", ".jpeg", ".png", ".gif"].includes(
path.extname(attachment.attachment)
)
) {
res.sendFile(path.resolve("usercontent/" + attachment.attachment))
} else {
res.download(
path.resolve("usercontent/" + attachment.attachment),
attachment.name
)
}
}
} catch (e) {
next(e)
}
})
module.exports = router

View file

@ -0,0 +1,287 @@
"use strict"
module.exports = {
up: async (queryInterface) =>
queryInterface.bulkInsert(
"Themes",
[
{
id: 1,
name: "Colubrina Classic",
userId: 1,
public: true,
theme: {
id: 1,
name: "Colubrina Classic",
primaryType: "all",
dark: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
bg: "#151515",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
},
light: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#f8f8f8",
toolbar: "#f8f8f8",
sheet: "#f8f8f8",
text: "#000000",
dark: "#f8f8f8",
bg: "#f8f8f8",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
}
},
createdAt: "2022-03-26 23:23:29",
updatedAt: "2022-03-26 23:23:29"
},
{
id: 2,
name: "Colubrina Gray",
userId: 1,
public: true,
theme: {
id: 2,
name: "Colubrina Gray",
primaryType: "all",
user: {
sussiId: "asdasd"
},
dark: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#262626",
toolbar: "#262626",
sheet: "#262626",
text: "#000000",
dark: "#262626",
bg: "#191919",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
},
light: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#dedede",
toolbar: "#dedede",
sheet: "#dedede",
text: "#000000",
dark: "#dedede",
bg: "#e7e7e7",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
}
},
createdAt: "2022-03-26 23:25:12",
updatedAt: "2022-03-26 23:25:12"
},
{
id: 3,
name: "Colubrina AMOLED (Black)",
userId: 1,
public: true,
theme: {
id: 3,
name: "Colubrina AMOLED",
primaryType: "dark",
dark: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#000000",
toolbar: "#121212",
sheet: "#000000",
text: "#000000",
dark: "#000000",
bg: "#000000",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
},
light: {
primary: "#0190ea",
secondary: "#757575",
accent: "#000000",
error: "#ff1744",
info: "#2196F3",
success: "#4CAF50",
warning: "#ff9800",
card: "#f8f8f8",
toolbar: "#f8f8f8",
sheet: "#f8f8f8",
text: "#000000",
dark: "#f8f8f8",
calendarNormalActivity: "#3f51b5",
calendarActivityType7: "#f44336",
calendarActivityType8: "#4caf50",
calendarActivityType10: "#ff9800",
calendarExternalActivity: "#2196f3"
}
},
createdAt: "2022-03-26 23:25:12",
updatedAt: "2022-03-26 23:25:12"
},
{
id: 4,
name: "Colubrina Grayscale",
userId: 1,
public: true,
theme: {
id: 5,
name: "Colubrina Grayscale",
primaryType: "all",
dark: {
primary: "#6E6E6E",
secondary: "#757575",
accent: "#000000",
error: "#616161",
info: "#7D7D7D",
success: "#868686",
warning: "#A6A6A6",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
bg: "#151515",
calendarNormalActivity: "#565656",
calendarActivityType7: "#767676",
calendarActivityType8: "#868686",
calendarActivityType10: "#A6A6A6",
calendarExternalActivity: "#7D7D7D"
},
light: {
primary: "#6E6E6E",
secondary: "#757575",
accent: "#000000",
error: "#616161",
info: "#7D7D7D",
success: "#868686",
warning: "#A6A6A6",
card: "#f8f8f8",
toolbar: "#f8f8f8",
sheet: "#f8f8f8",
text: "#000000",
dark: "#f8f8f8",
bg: "#f8f8f8",
calendarNormalActivity: "#565656",
calendarActivityType7: "#767676",
calendarActivityType8: "#868686",
calendarActivityType10: "#A6A6A6",
calendarExternalActivity: "#7D7D7D"
}
},
createdAt: "2022-03-26 23:25:12",
updatedAt: "2022-03-26 23:25:12"
},
{
id: 5,
name: "Colubrina High Contrast",
userId: 1,
public: true,
theme: {
id: 6,
name: "Colubrina High Contrast",
primaryType: "all",
dark: {
primary: "#0057E9",
secondary: "#757575",
accent: "#000000",
error: "#E11845",
info: "#0057E9",
success: "#87E911",
warning: "#F2CA19",
card: "#151515",
toolbar: "#191919",
sheet: "#181818",
text: "#000000",
dark: "#151515",
bg: "#151515",
calendarNormalActivity: "#0057E9",
calendarActivityType7: "#E11845",
calendarActivityType8: "#87E911",
calendarActivityType10: "#F2CA19",
calendarExternalActivity: "#0057E9"
},
light: {
primary: "#0057E9",
secondary: "#757575",
accent: "#000000",
error: "#E11845",
info: "#0057E9",
success: "#87E911",
warning: "#F2CA19",
card: "#f8f8f8",
toolbar: "#f8f8f8",
sheet: "#f8f8f8",
text: "#000000",
dark: "#f8f8f8",
bg: "#f8f8f8",
calendarNormalActivity: "#0057E9",
calendarActivityType7: "#E11845",
calendarActivityType8: "#87E911",
calendarActivityType10: "#F2CA19",
calendarExternalActivity: "#0057E9"
}
},
createdAt: "2022-03-26 23:25:12",
updatedAt: "2022-03-26 23:25:12"
}
],
{}
),
down: async (queryInterface, Sequelize) => {
/**
* Add commands to revert seed here.
*
* Example:
* await queryInterface.bulkDelete('People', null, {});
*/
}
}

2914
backend/yarn.lock Normal file

File diff suppressed because it is too large Load diff

86
package.json Normal file
View file

@ -0,0 +1,86 @@
{
"name": "colubrina-chat",
"version": "1.0.1",
"private": true,
"license": "GPL-3.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --no-clean",
"lint": "vue-cli-service lint",
"postinstall": "patch-package"
},
"dependencies": {
"@apollo/client": "^3.5.10",
"@babel/preset-env": "^7.17.10",
"@mdi/js": "^6.6.95",
"@sentry/tracing": "^6.19.3",
"@sentry/vue": "^6.19.3",
"apollo-boost": "^0.4.9",
"axios": "^0.26.1",
"brace": "^0.11.1",
"chart.js": "^3.7.1",
"core-js": "^3.6.5",
"dayjs": "^1.11.0",
"ejs": "^3.1.7",
"glob-parent": "^5.1.2",
"graphql": "^16.3.0",
"graphql-tag": "^2.12.6",
"markdown-it": "^13.0.1",
"markdown-it-emoji": "git+https://github.com/Troplo/markdown-it-unicode-emoji",
"node-ipc": "git+https://git.troplo.com/Troplo/node-ipc",
"nth-check": "^2.0.1",
"patch-package": "^6.4.7",
"prettier": "^2.6.1",
"register-service-worker": "^1.7.1",
"request": "^2.88.2",
"selfsigned": "^2.0.1",
"socket.io-client": "^4.5.1",
"twemoji": "^14.0.2",
"vue": "^2.6.11",
"vue-apollo": "^3.1.0",
"vue-axios": "^3.4.1",
"vue-chartjs": "^4.0.1",
"vue-final-modal": "^2.4.1",
"vue-matomo": "^4.1.0",
"vue-native-notification": "^1.1.1",
"vue-router": "^3.2.0",
"vue-sanitize": "^0.2.1",
"vue-shortkey": "^3.1.7",
"vue-swatches": "^2.1.1",
"vue-toastification": "^1.7.14",
"vue2-ace-editor": "^0.0.15",
"vuetify": "^2.6.4",
"vuex": "^3.4.0"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
"@mdi/font": "6.5.95",
"@sentry/webpack-plugin": "^1.18.8",
"@vue/cli-plugin-babel": "~4.5.15",
"@vue/cli-plugin-eslint": "~4.5.15",
"@vue/cli-plugin-pwa": "~4.5.15",
"@vue/cli-plugin-router": "~4.5.15",
"@vue/cli-plugin-vuex": "~4.5.15",
"@vue/cli-service": "~4.5.15",
"babel-eslint": "^10.1.0",
"dotenv-webpack": "^7.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"material-design-icons-iconfont": "^6.5.0",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "~2.4.7",
"vue-template-babel-compiler": "^1.1.3",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.0",
"webpack-auto-inject-version-next": "1.2.4"
},
"resolutions": {
"node-ipc": "git+https://git.troplo.com/Troplo/node-ipc",
"selfsigned": "^2.0.1",
"nth-check": "^2.0.1",
"glob-parent": "^5.1.2",
"ejs": "^3.1.7",
"eventsource": "^2.0.2"
}
}

View file

@ -0,0 +1,71 @@
diff --git a/node_modules/@mdi/font/.github/ISSUE_TEMPLATE.md b/node_modules/@mdi/font/.github/ISSUE_TEMPLATE.md
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/LICENSE b/node_modules/@mdi/font/LICENSE
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/README.md b/node_modules/@mdi/font/README.md
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/css/materialdesignicons.css b/node_modules/@mdi/font/css/materialdesignicons.css
old mode 100644
new mode 100755
index 7f09d7e..479d44b
--- a/node_modules/@mdi/font/css/materialdesignicons.css
+++ b/node_modules/@mdi/font/css/materialdesignicons.css
@@ -5,6 +5,7 @@
src: url("../fonts/materialdesignicons-webfont.eot?#iefix&v=6.5.95") format("embedded-opentype"), url("../fonts/materialdesignicons-webfont.woff2?v=6.5.95") format("woff2"), url("../fonts/materialdesignicons-webfont.woff?v=6.5.95") format("woff"), url("../fonts/materialdesignicons-webfont.ttf?v=6.5.95") format("truetype");
font-weight: normal;
font-style: normal;
+ font-display: swap;
}
.mdi:before,
diff --git a/node_modules/@mdi/font/css/materialdesignicons.css.map b/node_modules/@mdi/font/css/materialdesignicons.css.map
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/css/materialdesignicons.min.css b/node_modules/@mdi/font/css/materialdesignicons.min.css
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/css/materialdesignicons.min.css.map b/node_modules/@mdi/font/css/materialdesignicons.min.css.map
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/fonts/materialdesignicons-webfont.eot b/node_modules/@mdi/font/fonts/materialdesignicons-webfont.eot
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/fonts/materialdesignicons-webfont.ttf b/node_modules/@mdi/font/fonts/materialdesignicons-webfont.ttf
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/fonts/materialdesignicons-webfont.woff b/node_modules/@mdi/font/fonts/materialdesignicons-webfont.woff
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/fonts/materialdesignicons-webfont.woff2 b/node_modules/@mdi/font/fonts/materialdesignicons-webfont.woff2
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/preview.html b/node_modules/@mdi/font/preview.html
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_animated.scss b/node_modules/@mdi/font/scss/_animated.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_core.scss b/node_modules/@mdi/font/scss/_core.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_extras.scss b/node_modules/@mdi/font/scss/_extras.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_functions.scss b/node_modules/@mdi/font/scss/_functions.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_icons.scss b/node_modules/@mdi/font/scss/_icons.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_path.scss b/node_modules/@mdi/font/scss/_path.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/_variables.scss b/node_modules/@mdi/font/scss/_variables.scss
old mode 100644
new mode 100755
diff --git a/node_modules/@mdi/font/scss/materialdesignicons.scss b/node_modules/@mdi/font/scss/materialdesignicons.scss
old mode 100644
new mode 100755

View file

@ -0,0 +1,26 @@
diff --git a/node_modules/vuetify/src/components/VNavigationDrawer/VNavigationDrawer.sass b/node_modules/vuetify/src/components/VNavigationDrawer/VNavigationDrawer.sass
index ee4419a..6d1ba3d 100644
--- a/node_modules/vuetify/src/components/VNavigationDrawer/VNavigationDrawer.sass
+++ b/node_modules/vuetify/src/components/VNavigationDrawer/VNavigationDrawer.sass
@@ -9,7 +9,7 @@
background-color: map-get($material, 'dividers')
.v-divider
- border-color: map-get($material, 'dividers')
+ width: 0
// Block
.v-navigation-drawer
diff --git a/node_modules/vuetify/src/styles/settings/_dark.scss b/node_modules/vuetify/src/styles/settings/_dark.scss
index 753d70d..12980cc 100644
--- a/node_modules/vuetify/src/styles/settings/_dark.scss
+++ b/node_modules/vuetify/src/styles/settings/_dark.scss
@@ -6,7 +6,7 @@ $material-dark-elevation-colors: () !default;
$material-dark-elevation-colors: map-deep-merge(
(
'0': #000000,
- '1': #1E1E1E,
+ '1': #151515,
'2': #222222,
'3': #252525,
'4': #272727,

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1210" viewBox="0 0 1024 1210" version="1.1">
<path d="M 493.235 14.497 C 464.342 19.735, 439.862 34.705, 422.618 57.682 C 411.030 73.122, 404.162 90.199, 401.231 110.864 C 396.915 141.290, 406.950 173.469, 428.437 198.107 C 431.458 201.570, 433.832 204.501, 433.714 204.620 C 433.595 204.738, 425.399 206.460, 415.499 208.446 C 330.893 225.421, 258.467 260.158, 190.594 316.316 C 176.124 328.289, 142.713 361.542, 131.129 375.500 C 64.543 455.737, 26.508 545.245, 15.335 648 C 12.807 671.250, 12.807 724.750, 15.335 748 C 26.435 850.077, 64.513 940.174, 129.869 1019 C 142.140 1033.800, 176.200 1067.860, 191 1080.131 C 269.809 1145.473, 359.945 1183.568, 462 1194.665 C 485.250 1197.193, 538.750 1197.193, 562 1194.665 C 664.055 1183.568, 754.191 1145.473, 833 1080.131 C 847.800 1067.860, 881.860 1033.800, 894.131 1019 C 959.473 940.191, 997.568 850.055, 1008.665 748 C 1011.193 724.750, 1011.193 671.250, 1008.665 648 C 997.491 545.243, 959.525 455.889, 892.879 375.500 C 882.190 362.607, 847.393 327.810, 834.500 317.121 C 753.918 250.315, 665.493 212.767, 562 201.409 C 542.565 199.276, 501.701 198.504, 482.624 199.910 C 473.891 200.554, 466.563 200.896, 466.337 200.671 C 466.112 200.445, 472.131 199.295, 479.714 198.114 C 510.935 193.253, 518.993 192.686, 560.353 192.441 L 600.206 192.204 603.483 187.595 C 611.983 175.640, 619.858 155.514, 622.070 140.097 C 623.832 127.812, 622.765 108.836, 619.631 96.723 C 616.606 85.032, 610.051 70.794, 602.992 60.583 C 597.035 51.966, 583.177 38.231, 574.498 32.342 C 551.275 16.584, 519.825 9.678, 493.235 14.497 M 501.402 77.486 C 493.091 79.294, 485.691 83.233, 479.361 89.220 C 468.759 99.247, 464 110.148, 464 124.408 C 464 137.798, 467.832 147.630, 476.778 157.194 C 504.011 186.308, 552.645 171.168, 559.213 131.532 C 562.543 111.440, 551.389 90.310, 532.792 81.478 C 521.620 76.173, 512.669 75.034, 501.402 77.486 M 489.500 338.587 C 487.300 338.804, 480.550 339.453, 474.500 340.030 C 443.256 343.005, 408.828 351.492, 377 364.063 C 372.325 365.910, 360.625 371.362, 351 376.180 C 280.471 411.480, 225.500 466.451, 190.177 537 C 170.291 576.716, 159.668 612.641, 153.806 660 C 151.808 676.136, 152.130 723.084, 154.358 740.500 C 167.815 845.717, 223.199 936.928, 309.039 995.240 C 358.126 1028.586, 409.976 1048.112, 469.500 1055.667 C 489.165 1058.163, 534.835 1058.163, 554.500 1055.667 C 614.024 1048.112, 665.874 1028.586, 714.961 995.240 C 765.874 960.655, 805.893 914.784, 833.823 859 C 853.756 819.189, 864.433 783.084, 870.198 736 C 871.900 722.102, 871.894 673.828, 870.189 660 C 864.364 612.753, 853.711 576.720, 833.823 537 C 798.500 466.451, 743.529 411.480, 673 376.180 C 634.151 356.735, 598.148 345.906, 554 340.388 C 543.023 339.016, 497.913 337.756, 489.500 338.587 M 473 601 L 473 658 415.500 658 L 358 658 358 697 L 358 736 415.500 736 L 473 736 473 793 L 473 850 511.500 850 L 550 850 550 793 L 550 736 608 736 L 666 736 666 697 L 666 658 608 658 L 550 658 550 601 L 550 544 511.500 544 L 473 544 473 601" stroke="none" fill="black" fill-rule="evenodd"/>
</svg>

After

Width:  |  Height:  |  Size: 3 KiB

34
public/index.html Normal file
View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>Colubrina</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900&display=swap">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=JetBrains Mono:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Comic Neue:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open Sans:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<meta property="og:site_name" content="Colubrina">
<meta property="og:title" content="Colubrina">
<meta name="title" content="Colubrina">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="English">
</head>
<body>
<noscript>
<strong>We're sorry but Colubrina doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

971
src/App.vue Normal file
View file

@ -0,0 +1,971 @@
<template>
<v-app
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].bg
"
>
<v-overlay :value="$store.state.site.loading">
<v-progress-circular indeterminate size="64"></v-progress-circular>
</v-overlay>
<!-- theme engine editors -->
<vue-final-modal
v-model="$store.state.themeEngine.editor"
classes="modal-container"
content-class="modal-content"
:drag="true"
:hide-overlay="true"
:resize="false"
:click-to-close="false"
drag-selector=".editor__toolbar"
:prevent-click="true"
:lock-scroll="true"
>
<v-card
color="card lighten-1"
class="rounded-xl"
elevation="12"
max-width="900px"
max-height="700px"
>
<v-card-title color="toolbar" class="editor__toolbar v-toolbar">
<v-toolbar-title>
Theme
{{
$store.state.themeEngine.type === "create" ? "Creator" : "Editor"
}}
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<span v-on="on" v-bind="attrs">
<v-btn
fab
small
text
@click="$store.dispatch('randomizeTheme')"
>
<v-icon>mdi-dice-multiple</v-icon>
</v-btn>
</span>
</template>
<span> Randomize theme </span>
</v-tooltip>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click="$store.state.themeEngine.editor = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-container>
<v-alert type="info" text>
You can now view your changes in real time by navigating anywhere
throughout {{ $store.state.site.name }} with the editor open.
</v-alert>
<v-card-actions>
<v-btn
color="primary"
text
@click="
$store.dispatch('saveTheme', { theme: null, type: null })
$store.state.themeEngine.editor = false
"
>{{
$store.state.themeEngine.type === "create"
? "Create & Apply"
: "Save Edits"
}}</v-btn
>
<v-btn
color="primary"
text
@click="
$store.dispatch('saveTheme', { theme: null, type: 'copy' })
"
v-if="$store.state.themeEngine.type === 'edit'"
>Save a Copy</v-btn
>
<v-btn
color="error darken-1"
text
@click="$store.dispatch('discardTheme')"
>Discard</v-btn
>
</v-card-actions>
<v-form>
<v-text-field
v-model="$store.state.themeEngine.theme.name"
class="mx-3"
label="Theme Name"
required
></v-text-field>
<v-select
:items="intendedFor"
label="Intended for"
class="mx-3"
v-model="$store.state.themeEngine.theme.primaryType"
>
</v-select>
<v-text-field
v-model="creatorJSON"
label="JSON"
class="mx-3"
></v-text-field>
<v-btn @click="$store.state.themeEngine.cssEditor = true">
Custom CSS
</v-btn>
<h2
class="ml-2 mt-2 mb-3"
v-if="
$store.state.themeEngine.theme.primaryType === 'dark' ||
$store.state.themeEngine.theme.primaryType === 'all'
"
>
Dark:
</h2>
<v-row
v-if="
$store.state.themeEngine.theme.primaryType === 'dark' ||
$store.state.themeEngine.theme.primaryType === 'all'
"
>
<v-col
sm="3"
v-for="(item, index) in $store.state.themeEngine.theme.dark"
:key="index + '-dark-card'"
>
<v-card color="card">
<h3 class="ml-2 mt-2 mb-2">
{{ friendlyName(index) }}
</h3>
<v-menu offset-y>
<template v-slot:activator="{ on }">
<v-card
class="mb-2 mx-2"
:color="$store.state.themeEngine.theme.dark[index]"
v-on="on"
>
<v-container></v-container>
</v-card>
</template>
<v-color-picker
v-model="$store.state.themeEngine.theme.dark[index]"
show-swatches
hide-inputs
></v-color-picker>
</v-menu>
<v-text-field
class="mx-2"
label="#HEX"
v-model="$store.state.themeEngine.theme.dark[index]"
></v-text-field>
</v-card>
</v-col>
</v-row>
<h2
class="ml-2 mt-2 mb-3"
v-if="
$store.state.themeEngine.theme.primaryType === 'light' ||
$store.state.themeEngine.theme.primaryType === 'all'
"
>
Light:
</h2>
<v-row
v-if="
$store.state.themeEngine.theme.primaryType === 'light' ||
$store.state.themeEngine.theme.primaryType === 'all'
"
>
<v-col
sm="3"
v-for="(item, index) in $store.state.themeEngine.theme.light"
:key="index + '-light-card'"
>
<v-card color="card">
<h3 class="ml-2 mt-2 mb-2">
{{ friendlyName(index) }}
</h3>
<v-menu offset-y>
<template v-slot:activator="{ on }">
<v-card
class="mb-2 mx-2"
:color="$store.state.themeEngine.theme.light[index]"
v-on="on"
>
<v-container></v-container>
</v-card>
</template>
<v-color-picker
v-model="$store.state.themeEngine.theme.light[index]"
show-swatches
hide-inputs
></v-color-picker>
</v-menu>
<v-text-field
class="mx-2"
label="#HEX"
v-model="$store.state.themeEngine.theme.light[index]"
></v-text-field>
</v-card>
</v-col>
</v-row>
</v-form>
<v-card-actions>
<v-btn
color="primary"
text
@click="
$store.dispatch('saveTheme', { theme: null, type: null })
$store.state.themeEngine.editor = false
"
>{{
$store.state.themeEngine.type === "create"
? "Create & Apply"
: "Save Edits"
}}</v-btn
>
<v-btn
color="primary"
text
@click="
$store.dispatch('saveTheme', { theme: null, type: 'copy' })
"
v-if="$store.state.themeEngine.type === 'edit'"
>Save a Copy</v-btn
>
<v-btn
color="error darken-1"
text
@click="$store.dispatch('discardTheme')"
>Discard</v-btn
>
</v-card-actions>
</v-container>
</v-card>
</vue-final-modal>
<vue-final-modal
ref="editor-modal"
v-model="$store.state.themeEngine.cssEditor"
classes="modal-container"
content-class="modal-content"
:drag="true"
:hide-overlay="true"
:resize="true"
:resize-directions="['r', 'l']"
:min-width="400"
:focus-retain="true"
:click-to-close="false"
drag-selector=".editor__toolbar"
:prevent-click="true"
:lock-scroll="false"
>
<v-card
min-width="100%"
color="card lighten-1"
class="rounded-xl"
elevation="7"
style="border-radius: 0; padding: 0"
>
<v-card-title color="toolbar" class="editor__toolbar v-toolbar">
<v-toolbar-title>CSS Editor</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click="$store.state.themeEngine.cssEditor = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-container>
<v-row>
<v-col>
<v-alert type="info" text class="editor__toolbar">
CTRL + ALT + D / F9 will toggle all custom CSS styling, works
anywhere, even outside the editor.</v-alert
>
<v-switch
inset
label="Live update"
v-model="$store.state.themeEngine.autoCSS"
></v-switch>
<v-btn
icon
class="mb-2"
@click="
$store.dispatch('saveTheme', { theme: null, type: null })
$store.dispatch('applyCSS', null)
"
>
<v-icon>mdi-content-save</v-icon>
</v-btn>
<v-btn
icon
class="mb-2"
@click="$store.dispatch('applyCSS', null)"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
<editor
class="editor"
v-model="$store.state.themeEngine.theme.css"
@init="editorInit"
lang="css"
:theme="$vuetify.theme.dark ? 'monokai' : 'chrome'"
height="350"
></editor>
</v-col>
<v-col v-if="cssTips">
<v-card-title>
Tips
<v-spacer></v-spacer>
<v-btn icon @click="cssTips = false">
<v-icon>mdi-close</v-icon>
</v-btn></v-card-title
>
<v-alert type="error" text>
This is an alert.<br />
Try to style it with .v-alert</v-alert
>
Here's an example:<br />
<code class="block"
>.v-alert {<br />
background-color: blue !important; <br />}
</code>
<v-btn
class="mt-2 mr-2"
@click="$toast.success('I have been pressed.')"
>Here's a button</v-btn
>
<v-btn
class="mt-2"
text
color="info"
@click="$toast.info('This is the second button\'s action.')"
>Here's another one</v-btn
>
<v-card-title> Fonts </v-card-title>
<code
class="block"
style="white-space: pre-line; overflow-wrap: anywhere"
>
/* Stop from font breaking CSS code editor */<br />
.ace_editor div {<br />
&nbsp;font-family: "JetBrains Mono" !important; <br />}<br />
div {<br />
&nbsp;font-family: "Inter", sans-serif;
<br />}
</code>
There are little pre-loaded fonts you can use, they include:
<ul>
<li>Roboto (Default)</li>
<li>Inter</li>
<li>JetBrains Mono</li>
</ul>
You may import your own fonts using
<code>@import</code>, or use system fonts.
</v-col>
</v-row>
<v-card-actions>
<v-spacer />
<v-btn
color="blue darken-1"
text
@click="
$store.dispatch('saveTheme', { theme: null, type: null })
$store.dispatch('applyCSS', null)
$store.state.themeEngine.cssEditor = false
"
>
Save Changes
</v-btn>
</v-card-actions>
</v-container>
</v-card>
</vue-final-modal>
<!-- end theme engine editors -->
<v-dialog v-model="$store.state.modals.search" max-width="600px">
<v-card color="card">
<v-toolbar color="toolbar">
<v-toolbar-title>
{{ $store.state.site.name }} QuickSwitcher
</v-toolbar-title>
</v-toolbar>
<v-container>
<v-autocomplete
auto-select-first
v-model="search"
:items="$store.state.quickSwitchCache"
item-text="subjectLongName"
label="Search"
outlined
autofocus
return-object
:search-input.sync="searchInput"
>
</v-autocomplete>
</v-container>
</v-card>
</v-dialog>
<v-main>
<Header></Header>
<v-container
v-if="
$store.state.user?.compact === 'nagPending' &&
$vuetify.breakpoint.lgAndDown &&
!$vuetify.breakpoint.mobile
"
>
<v-alert dense text color="info" dismissible v-model="compactModeNag">
Introducing <strong>Compact Mode</strong>, a better experience for
lower resolution devices.
<v-btn
to="/settings/appearance"
text
color="primary"
outlined
class="ml-1"
>
Settings
</v-btn>
</v-alert>
</v-container>
<v-container
v-if="$store.state.site.latestVersion > $store.state.versioning.version"
id="update-notify-banner"
>
<v-alert class="mx-4 rounded-xl" type="info" text dismissible>
{{ $store.state.site.name }} just got better. Please CTRL+R / +R to
update. (You are on version {{ $store.state.versioning.version }}, and
the latest version is {{ $store.state.site.latestVersion }})
</v-alert>
</v-container>
<v-container
v-if="$store.state.site.notification && $store.state.user"
id="notification-banner"
>
<v-alert
text
class="mx-4 rounded-xl"
dismissible
:type="$store.state.site.notificationType"
>
{{ $store.state.site.notification }}
</v-alert>
</v-container>
<v-container v-if="!$store.state.online" id="offline-notify-banner">
<v-alert text class="mx-4" type="warning">
You are currently offline. {{ $store.state.site.name }} functionality
is limited.
</v-alert>
</v-container>
<router-view
:style="
'background-color: ' +
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].bg
"
/>
</v-main>
</v-app>
</template>
<style></style>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import Vue from "vue"
import Vuetify from "@/plugins/vuetify"
import { VueFinalModal } from "vue-final-modal"
import Header from "@/components/Header"
export default {
name: "App",
components: {
VueFinalModal,
Header,
editor: require("vue2-ace-editor")
},
data: () => ({
compactModeNag: true,
intendedFor: [
{ text: "All base themes", value: "all" },
{ text: "Dark theme", value: "dark" },
{ text: "Light theme", value: "light" }
],
loading: false,
defineAccent: false,
accent: "#0179f3",
loadingGuidedWizard: false,
guidedWizard: {
step: 1
},
connectionLoading: false,
update: false,
search: "",
results: [],
searchInput: null,
themes: [],
cssTips: true
}),
computed: {
creatorJSON: {
get() {
return JSON.stringify(this.$store.state.themeEngine.theme)
},
set(value) {
this.$store.state.themeEngine.theme = JSON.parse(value)
}
},
today() {
return this.$date().format("YYYY-MM-DD")
},
computeThemes() {
let array = []
if (this.$vuetify.theme.dark) {
array = this.themes.filter(
(theme) => theme.primaryType === "dark" || theme.primaryType === "all"
)
return array
} else {
array = this.themes.filter(
(theme) =>
theme.primaryType === "light" || theme.primaryType === "all"
)
return array
}
}
},
methods: {
communicationsIdleCheck() {
let time
let idle = false
window.onload = resetTimer
document.onmousemove = resetTimer
document.onkeydown = resetTimer
document.onmousedown = resetTimer
let self = this
function setIdle() {
if (!idle) {
self.$socket.emit("idle")
idle = true
console.log("idle")
} else {
self.$socket.emit("online")
idle = false
console.log("online")
}
}
function resetTimer() {
clearTimeout(time)
if (idle) {
setIdle()
}
time = setTimeout(
function () {
setIdle()
}.bind(this.$socket),
300000
)
}
},
friendlyName(index) {
if (index === "calendarNormalActivity") {
return "Standard Class"
} else if (index === "calendarActivityType7") {
return "Relief Event"
} else if (index === "calendarActivityType8") {
return "Generic Type 8"
} else if (index === "calendarActivityType10") {
return "Learning Task"
} else if (index === "calendarExternalActivity") {
return "External Activity"
} else if (index === "bg") {
return "Background"
} else if (index === "dark") {
return "Sidebar & Header"
} else {
return index.charAt(0).toUpperCase() + index.slice(1)
}
},
computeColor(event) {
if (this.$vuetify?.theme?.themes) {
if (event.color === "#003300") {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarActivityType8
} else if (event.color === "#133897") {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarExternalActivity
} else if (event.activityType === 7 || event.color === "#f4dcdc") {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarActivityType7
} else if (event.color === "#dce6f4") {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarNormalActivity
} else if (event.activityType === 10) {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarActivityType10
} else {
return this.$vuetify.theme.themes[
this.$store.state.user.theme || "dark"
].calendarNormalActivity
}
}
},
editorInit() {
require("brace/ext/language_tools")
require("brace/mode/css")
require("brace/mode/less")
require("brace/theme/monokai")
require("brace/theme/chrome")
require("brace/snippets/css")
},
baseRole() {
if (this.$store.state.user?.baseRole) {
return (
this.$store.state.user.baseRole
.toLowerCase()
.charAt(0)
.toUpperCase() +
this.$store.state.user.baseRole.toLowerCase().slice(1)
)
} else {
return "Not Authenticated"
}
},
saveSettings() {
this.loading = true
this.$vuetify.theme.dark = this.$store.state.user?.theme === "dark"
this.$store
.dispatch("saveOnlineSettings")
.then(() => {
this.loading = false
})
.catch((e) => {
this.loading = false
AjaxErrorHandler(this.$store)(e)
})
},
completeGuidedWizard() {
this.loadingGuidedWizard = true
this.$store.dispatch("saveOnlineSettings", {
guidedWizard: false
})
this.$store.dispatch("getUserInfo").then(() => {
this.loadingGuidedWizard = false
})
},
getThemes() {
this.axios.get("/api/v1/themes").then((res) => {
this.themes = res.data.map((theme) => {
return {
id: theme.id,
name: theme.name,
primaryType: theme.theme.primaryType,
dark: theme.theme.dark,
light: theme.theme.light,
public: theme.public,
user: theme.user,
userId: theme.userId
}
})
})
},
setTheme(theme) {
const name = theme.id
const dark = theme.dark
const light = theme.light
this.$vuetify.theme.themes.dark = dark
this.$vuetify.theme.themes.light = light
this.$vuetify.theme.themes.name = name
this.$vuetify.theme.themes.primaryType = theme.primaryType
if (this.accent && this.defineAccent) {
this.$vuetify.theme.themes.light.primary = this.accent
this.$vuetify.theme.themes.dark.primary = this.accent
this.$store.state.user.accentColor = this.accent
} else {
this.$store.state.user.accentColor = null
}
this.name = name
this.axios
.put("/api/v1/user/settings/theme", {
id: name,
accent: this.defineAccent ? this.accent : null
})
.catch((e) => {
AjaxErrorHandler(this.$store)(e)
})
},
retryConnection() {
this.connectionLoading = true
this.$store.dispatch("getState").finally(() => {
this.connectionLoading = false
})
},
validate(value, defaultValue) {
if (value === undefined || value === null) {
return defaultValue
} else {
return value
}
}
},
mounted() {
if (localStorage.getItem("cssTipsDismissed")) {
this.cssTips = false
}
window.addEventListener("offline", () => {
this.$store.commit("setOnline", false)
this.$store.dispatch("getState")
})
window.addEventListener("online", () => {
this.$store.commit("setOnline", true)
this.$store.dispatch("getState")
this.$store.dispatch("getUserInfo")
})
this.$socket.connect()
Vue.axios.defaults.headers.common["CompassAPIKey"] =
localStorage.getItem("apiKey")
Vue.axios.defaults.headers.common["Authorization"] =
localStorage.getItem("bcToken")
document.title = this.$route.name
? this.$route.name + " - " + this.$store.state.site.name
: this.$store.state.site.name
this.$store.commit("setLoading", true)
this.$vuetify.theme.dark = this.$store.state.user?.theme === "dark" || true
this.axios.defaults.headers.common["compassInstance"] =
localStorage.getItem("schoolInstance")
this.axios.defaults.headers.common["compassSchoolId"] =
localStorage.getItem("schoolId")
if (JSON.parse(localStorage.getItem("userCache"))?.id) {
const user = JSON.parse(localStorage.getItem("userCache"))
const name = user.themeObject.id
const dark = user.themeObject.theme.dark
const light = user.themeObject.theme.light
if (user.accentColor) {
user.themeObject.theme.dark.primary = user.accentColor
user.themeObject.theme.light.primary = user.accentColor
}
if (JSON.parse(localStorage.getItem("subjectsCache"))) {
this.$store.commit(
"setSubjects",
JSON.parse(localStorage.getItem("subjectsCache"))
)
}
Vuetify.framework.theme.themes.dark = dark
Vuetify.framework.theme.themes.light = light
Vuetify.framework.theme.themes.name = name
Vuetify.framework.theme.themes.primaryType =
user.themeObject.theme.primaryType
this.$store.commit(
"setUser",
JSON.parse(localStorage.getItem("userCache"))
)
}
if (localStorage.getItem("calendarCache")?.length) {
this.$store.commit(
"setCalendar",
JSON.parse(localStorage.getItem("calendarCache")).map((event) => {
return {
...event,
start: new Date(event.start),
end: new Date(event.finish)
}
})
)
}
this.$store.dispatch("getState")
this.$store.dispatch("checkAuth").catch(() => {
this.$store.dispatch("logout")
this.$router.push("/login")
})
this.getThemes()
this.$store
.dispatch("getUserInfo")
.then(() => {
this.communicationsIdleCheck()
this.$store.dispatch("getCommunicationsUnread")
this.$socket.on("message", (message) => {
this.$store.state.communicationNotifications += 1
if (
(this.$route.name !== "Communications" &&
this.$store.state.user.storedStatus !== "busy") ||
(this.$route.name === "Communications" &&
!document.hasFocus() &&
this.$store.state.user.storedStatus !== "busy")
) {
if (localStorage.getItem("messageAudio")) {
if (JSON.parse(localStorage.getItem("messageAudio"))) {
new Audio(require("@/assets/audio/message.wav")).play()
}
} else {
new Audio(require("@/assets/audio/message.wav")).play()
}
this.$notification.show(
message.user.username + " (" + message.chat.name + ")",
{
body: message.content,
icon: message.user.avatar
? "/usercontent/" + message.user.avatar
: null
},
{}
)
this.$toast.info(
"Message: " +
message.content +
"\n\n" +
"From: " +
message.user.username +
"\n" +
"Sent in: " +
message.chat.name,
{
onClick: () => {
this.$router.push("/communications/" + message.associationId)
}
}
)
}
})
if (this.$store.state.user.storedStatus !== "busy") {
this.$socket.on("friendRequest", (message) => {
this.$notification.show(
message.user.username,
{
body: message.user.username + " has sent a friend request",
icon: message.user.avatar
? "/usercontent/" + message.user.avatar
: null
},
{}
)
new Audio(require("@/assets/audio/message.wav")).play()
this.$toast.info("Friend request sent by " + message.user.username)
})
}
this.$store.commit("setWSConnected", true)
this.$socket.on("disconnect", () => {
this.$store.commit("setWSConnected", false)
})
this.$socket.on("connect", () => {
this.$store.commit("setWSConnected", true)
})
this.$socket.on("siteState", (state) => {
this.$store.state.site.latestVersion = state.latestVersion
this.$store.state.site.notification = state.notification
this.$store.state.site.notificationType = state.notificationType
})
setInterval(() => {
this.$socket.emit("ping")
}, 10000)
// eslint-disable-next-line no-undef
if (JSON.parse(process.env.VUE_APP_MATOMO_ENABLED)) {
// eslint-disable-next-line no-undef
_paq.push(["setUserId", this.$store.state.user.id])
// eslint-disable-next-line no-undef
_paq.push(["trackPageView"])
}
this.$store.dispatch("updateQuickSwitch")
})
.catch(() => {
this.$router.push("/login")
})
},
watch: {
compactModeNag(val) {
if (!val) {
this.$store.state.user.compact = "disabled"
this.$store.dispatch("saveOnlineSettings")
}
},
cssTips(val) {
localStorage.setItem("cssTipsDismissed", !val)
},
"$store.state.themeEngine.theme": {
handler() {
this.$vuetify.theme.themes.dark =
this.$store.state.themeEngine.theme.dark
this.$vuetify.theme.themes.light =
this.$store.state.themeEngine.theme.light
this.$vuetify.theme.themes.name = this.$store.state.themeEngine.theme.id
},
deep: true
},
"$store.state.themeEngine.theme.css"() {
if (this.$store.state.themeEngine.autoCSS) {
this.$store.dispatch("applyCSS", null)
}
},
"$store.state.user.theme": {
handler() {
if (this.$store.state.user?.theme) {
this.$vuetify.theme.dark = this.$store.state.user.theme === "dark"
}
},
deep: true
},
$route(to) {
document.title = to.name + " - " + this.$store.state.site.name
},
search() {
if (this.search) {
if (this.search.id) {
this.$router.push("/activity/activity/" + this.search.id)
this.$store.commit("setSearch", false)
this.search = null
this.$nextTick(() => {
this.searchInput = null
})
} else if (this.search.customType === 1) {
this.$router.push(this.search.route)
this.$store.commit("setSearch", false)
this.search = null
this.$nextTick(() => {
this.searchInput = null
})
}
}
}
}
}
</script>
<style scoped>
::v-deep .modal-container {
display: flex;
justify-content: center;
align-items: center;
}
::v-deep .modal-content {
position: relative;
display: flex;
flex-direction: column;
max-height: 90%;
margin: 0 1rem;
padding: 1rem;
border-radius: 0.25rem;
}
.editor__toolbar {
}
.editor {
height: 100%;
width: 100%;
border-radius: inherit !important;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1) !important;
padding: 20px !important;
overflow: hidden !important;
background: inherit;
font-family: "JetBrains Mono", monospace !important;
}
.ace_gutter {
background: inherit !important;
}
.block {
display: block;
background: none;
white-space: pre;
-webkit-overflow-scrolling: touch;
overflow-x: scroll;
max-width: 100%;
min-width: 100px;
padding: 0;
}
</style>

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Some files were not shown because too many files have changed in this diff Show more