Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Untangle client and server #4861

Merged
merged 95 commits into from Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
3eb1913
wip: msg
brunnre8 Feb 15, 2024
68ba13c
wip: searchquery
brunnre8 Feb 15, 2024
b67e469
wip sharedmsg in client
brunnre8 Feb 24, 2024
3f0ee6a
move chan enums
brunnre8 Feb 24, 2024
d0b71ab
shared: extract chan + user
brunnre8 Feb 24, 2024
d716402
mention
brunnre8 Feb 24, 2024
12a0b0b
network
brunnre8 Feb 24, 2024
f0ee3be
wip: config
brunnre8 Feb 24, 2024
383907c
Use SharedTypes
brunnre8 Feb 24, 2024
4d23760
changelog: don't type assert to a broken type
brunnre8 Feb 24, 2024
7bc184b
changelog data type
brunnre8 Feb 24, 2024
8e6920a
configuration
brunnre8 Feb 29, 2024
7073584
fix msg event
brunnre8 Mar 1, 2024
88c8830
chatuserlist
brunnre8 Mar 1, 2024
194b4e1
import fix
brunnre8 Mar 1, 2024
3217536
searchresponse
brunnre8 Mar 1, 2024
e57e547
further chan fixes
brunnre8 Mar 3, 2024
e43cbb1
remove all server files from compilation
brunnre8 Mar 3, 2024
6984e8f
unused import
brunnre8 Mar 3, 2024
636b5c5
models/network: unfuck client export
brunnre8 Mar 3, 2024
9aee3e3
Some whitespace is good mkey
brunnre8 Mar 3, 2024
c869ea9
sharedchans does not have users
brunnre8 Mar 3, 2024
b89b0ca
client: id is always a string, not a number
brunnre8 Mar 3, 2024
fceffd4
fix missing import
brunnre8 Mar 24, 2024
e9ef59b
fix bad typing
brunnre8 Mar 24, 2024
843db17
server: actually type the socket
brunnre8 Mar 24, 2024
0067c30
Split sort event
brunnre8 Mar 24, 2024
f5c691f
wip: unbork init progress
brunnre8 Mar 24, 2024
0660a87
server: fix getFilteredClone of chan
brunnre8 Apr 1, 2024
9ab9ad0
socket-events: fix up init
brunnre8 Apr 1, 2024
5621538
server: remove static props which are currently unused
brunnre8 Apr 1, 2024
46f3fd9
server: fix push subscription
brunnre8 Apr 1, 2024
60486bf
server: fix init client
brunnre8 Apr 1, 2024
a8e7022
fix search event params
brunnre8 Apr 7, 2024
98452cc
remove obsolete import
brunnre8 Apr 7, 2024
e15b121
remove obsolete error override
brunnre8 Apr 7, 2024
5ee9c2b
type Server
brunnre8 Apr 7, 2024
bf7eb0e
network event: remove unused array
brunnre8 Apr 7, 2024
35e38d1
client: properly type the emit method
brunnre8 Apr 7, 2024
9c4d24d
fix join socket type
brunnre8 Apr 7, 2024
1c4ce5d
fix sync_sort:channels emitter
brunnre8 Apr 7, 2024
c20cd6b
publicClient: add FIXME and ignore the type mismatch
brunnre8 Apr 7, 2024
fe4f497
fix socket-event: network
brunnre8 Apr 7, 2024
3ea5170
socket-events: fix network:status
brunnre8 Apr 7, 2024
29750a3
ClientChan: does need a user array after all
brunnre8 Apr 7, 2024
1565eb8
socket-events/msg: if/else chains are not a switch replacement
brunnre8 Apr 8, 2024
42ea66c
socket-events/msg: fix errors
brunnre8 Apr 8, 2024
300bd4c
add timestamp to NotificationOptions
brunnre8 Apr 13, 2024
bfca0ca
fix more
brunnre8 Apr 13, 2024
7287c6b
remove dead import
brunnre8 Apr 13, 2024
5003764
socket-events: fix join
brunnre8 Apr 13, 2024
14b9169
store: fix import
brunnre8 Apr 13, 2024
4d0474b
store: don't duplicate import
brunnre8 Apr 13, 2024
0311e5f
add socket-events import to entry point
brunnre8 Apr 13, 2024
17ba07d
fix mentions import
brunnre8 Apr 13, 2024
9f2c82e
fix mentions
brunnre8 Apr 13, 2024
9898f38
add todo
brunnre8 Apr 13, 2024
bb7c392
type serverOptions for network:options
brunnre8 Apr 13, 2024
540144c
chan: remove cast in pushMessage
brunnre8 Apr 14, 2024
4614c35
chan: type untyped method params
brunnre8 Apr 14, 2024
a4afa08
ldap: type SearchOptions scope
brunnre8 Apr 14, 2024
b8a9fe0
clientCertificate: remove unsafe casts
brunnre8 Apr 14, 2024
5274fdc
ignore: keep happy path on the left
brunnre8 Apr 14, 2024
071a5af
ignore: move ignorelist to its own command
brunnre8 Apr 14, 2024
b8400a3
ignore: clean up the types and conditionals
brunnre8 Apr 14, 2024
917fdb2
ignore: remove dead import
brunnre8 Apr 14, 2024
c3fc54e
ignorelist: shut up the linter
brunnre8 Apr 14, 2024
5c8951f
fix extractTargetGroup typing
brunnre8 Apr 15, 2024
edb96f6
cap: type the boolean
brunnre8 Apr 15, 2024
92a0aff
kick: use the user object
brunnre8 Apr 15, 2024
e2b56cf
irc-events/message: fix types
brunnre8 Apr 15, 2024
8c41356
publicClient: type fix
brunnre8 Apr 17, 2024
5001d60
server: mark req params as unused
brunnre8 Apr 17, 2024
e61e356
server: somewhat type fix auth related functions
brunnre8 Apr 17, 2024
82e4150
server: remove type cast from change pw
brunnre8 Apr 17, 2024
fc98055
sharedMsg: remove userAway
brunnre8 Apr 21, 2024
4b07e05
client: add missing import for SharedMsg
brunnre8 Apr 21, 2024
96848c1
msg_preview: fix possibly undefined error
brunnre8 Apr 21, 2024
f25fee4
previews: fix possibly undefined
brunnre8 Apr 21, 2024
4ceafb6
test/client: fix import path
brunnre8 Apr 17, 2024
31d9872
fix mode tests
brunnre8 Apr 17, 2024
1edb5a7
test/models/chan: we do not send an empty user list anymore
brunnre8 Apr 17, 2024
c866430
test/models/msg: fix linkpreview import
brunnre8 Apr 17, 2024
5e444be
test/models/network: fix import path
brunnre8 Apr 17, 2024
7f5e0f3
test/plugins/link: fix import path
brunnre8 Apr 17, 2024
03151e0
test/plugins/sqlite: fix import path
brunnre8 Apr 17, 2024
6241eed
client/ImageViewer: fix types and guard against undefined
brunnre8 Apr 21, 2024
6c9d2c3
components/Message: fix eslint errors
brunnre8 Apr 21, 2024
91ac363
components/MessageTypes/errors: fix eslint errors
brunnre8 Apr 21, 2024
a200bab
test/chan: getFilteredClone has more fields than the test thinks
brunnre8 Apr 21, 2024
5567f07
test/chan: remove users field from test
brunnre8 Apr 21, 2024
8372c5a
test: token in init event payload is undefined not null
brunnre8 Apr 21, 2024
1ec67a6
test/sqlite: remove unused eslint directive
brunnre8 Apr 21, 2024
36cb75e
NetworkForm: disable unsafe return lints for now
brunnre8 Apr 21, 2024
8eb398c
server: don't throw in async callback from index requests
brunnre8 Apr 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/components/ChatUserList.vue
Expand Up @@ -59,7 +59,7 @@
<script lang="ts">
import {filter as fuzzyFilter} from "fuzzy";
import {computed, defineComponent, nextTick, PropType, ref} from "vue";
import type {UserInMessage} from "../../server/models/msg";
import type {UserInMessage} from "../../shared/types/msg";
import type {ClientChan, ClientUser} from "../js/types";
import Username from "./Username.vue";

Expand Down Expand Up @@ -104,7 +104,7 @@ export default defineComponent({
const result = filteredUsers.value;

for (const user of result) {
const mode = user.original.modes[0] || "";
const mode: string = user.original.modes[0] || "";

if (!groups[mode]) {
groups[mode] = [];
Expand Down
8 changes: 4 additions & 4 deletions client/components/ImageViewer.vue
Expand Up @@ -41,9 +41,9 @@
<script lang="ts">
import Mousetrap from "mousetrap";
import {computed, defineComponent, ref, watch} from "vue";
import {onBeforeRouteLeave, onBeforeRouteUpdate} from "vue-router";
import eventbus from "../js/eventbus";
import {ClientChan, ClientMessage, ClientLinkPreview} from "../js/types";
import {ClientChan, ClientLinkPreview} from "../js/types";
import {SharedMsg} from "../../shared/types/msg";

export default defineComponent({
name: "ImageViewer",
Expand Down Expand Up @@ -104,9 +104,9 @@ export default defineComponent({
}

const links = channel.value.messages
.map((msg) => msg.previews)
.map((msg: SharedMsg) => msg.previews)
.flat()
.filter((preview) => preview.thumb);
.filter((preview) => preview && preview.thumb);

const currentIndex = links.indexOf(link.value);

Expand Down
6 changes: 5 additions & 1 deletion client/components/Message.vue
Expand Up @@ -150,10 +150,14 @@ export default defineComponent({
});

const messageComponent = computed(() => {
return "message-" + props.message.type;
return "message-" + (props.message.type || "invalid"); // TODO: force existence of type in sharedmsg
});

const isAction = () => {
if (!props.message.type) {
return false;
}

return typeof MessageTypes["message-" + props.message.type] !== "undefined";
};

Expand Down
6 changes: 3 additions & 3 deletions client/components/MessageList.vue
Expand Up @@ -79,7 +79,7 @@ import {
} from "vue";
import {useStore} from "../js/store";
import {ClientChan, ClientMessage, ClientNetwork, ClientLinkPreview} from "../js/types";
import Msg from "../../server/models/msg";
import {SharedMsg} from "../../shared/types/msg";

type CondensedMessageContainer = {
type: "condensed";
Expand Down Expand Up @@ -242,7 +242,7 @@ export default defineComponent({
});

const shouldDisplayDateMarker = (
message: Msg | ClientMessage | CondensedMessageContainer,
message: SharedMsg | ClientMessage | CondensedMessageContainer,
id: number
) => {
const previousMessage = condensedMessages.value[id - 1];
Expand Down Expand Up @@ -270,7 +270,7 @@ export default defineComponent({
return false;
};

const isPreviousSource = (currentMessage: ClientMessage | Msg, id: number) => {
const isPreviousSource = (currentMessage: ClientMessage | SharedMsg, id: number) => {
const previousMessage = condensedMessages.value[id - 1];
return !!(
previousMessage &&
Expand Down
29 changes: 18 additions & 11 deletions client/components/MessageTypes/error.vue
Expand Up @@ -26,36 +26,43 @@ export default defineComponent({
},
setup(props) {
const errorMessage = computed(() => {
// TODO: enforce chan and nick fields so that we can get rid of that
const chan = props.message.channel || "!UNKNOWN_CHAN";
const nick = props.message.nick || "!UNKNOWN_NICK";

switch (props.message.error) {
case "bad_channel_key":
return `Cannot join ${props.message.channel} - Bad channel key.`;
return `Cannot join ${chan} - Bad channel key.`;
case "banned_from_channel":
return `Cannot join ${props.message.channel} - You have been banned from the channel.`;
return `Cannot join ${chan} - You have been banned from the channel.`;
case "cannot_send_to_channel":
return `Cannot send to channel ${props.message.channel}`;
return `Cannot send to channel ${chan}`;
case "channel_is_full":
return `Cannot join ${props.message.channel} - Channel is full.`;
return `Cannot join ${chan} - Channel is full.`;
case "chanop_privs_needed":
return "Cannot perform action: You're not a channel operator.";
case "invite_only_channel":
return `Cannot join ${props.message.channel} - Channel is invite only.`;
return `Cannot join ${chan} - Channel is invite only.`;
case "no_such_nick":
return `User ${props.message.nick} hasn't logged in or does not exist.`;
return `User ${nick} hasn't logged in or does not exist.`;
case "not_on_channel":
return "Cannot perform action: You're not on the channel.";
case "password_mismatch":
return "Password mismatch.";
case "too_many_channels":
return `Cannot join ${props.message.channel} - You've already reached the maximum number of channels allowed.`;
return `Cannot join ${chan} - You've already reached the maximum number of channels allowed.`;
case "unknown_command":
return `Unknown command: ${props.message.command}`;
// TODO: not having message.command should never happen, so force existence
return `Unknown command: ${props.message.command || "!UNDEFINED_COMMAND_BUG"}`;
case "user_not_in_channel":
return `User ${props.message.nick} is not on the channel.`;
return `User ${nick} is not on the channel.`;
case "user_on_channel":
return `User ${props.message.nick} is already on the channel.`;
return `User ${nick} is already on the channel.`;
default:
if (props.message.reason) {
return `${props.message.reason} (${props.message.error})`;
return `${props.message.reason} (${
props.message.error || "!UNDEFINED_ERR"
})`;
}

return props.message.error;
Expand Down
2 changes: 2 additions & 0 deletions client/components/NetworkForm.vue
Expand Up @@ -498,6 +498,7 @@ export default defineComponent({
};

watch(
// eslint-disable-next-line
() => props.defaults?.commands,
() => {
void nextTick(() => {
Expand All @@ -507,6 +508,7 @@ export default defineComponent({
);

watch(
// eslint-disable-next-line
() => props.defaults?.tls,
(isSecureChecked) => {
const ports = [6667, 6697];
Expand Down
8 changes: 3 additions & 5 deletions client/components/NetworkList.vue
Expand Up @@ -309,8 +309,7 @@ export default defineComponent({

moveItemInArray(store.state.networks, oldIndex, newIndex);

socket.emit("sort", {
type: "networks",
socket.emit("sort:networks", {
order: store.state.networks.map((n) => n.uuid),
});
};
Expand Down Expand Up @@ -341,9 +340,8 @@ export default defineComponent({

moveItemInArray(netChan.network.channels, oldIndex, newIndex);

socket.emit("sort", {
type: "channels",
target: netChan.network.uuid,
socket.emit("sort:channel", {
network: netChan.network.uuid,
order: netChan.network.channels.map((c) => c.id),
});
};
Expand Down
4 changes: 2 additions & 2 deletions client/components/Username.vue
Expand Up @@ -12,10 +12,10 @@

<script lang="ts">
import {computed, defineComponent, PropType} from "vue";
import {UserInMessage} from "../../server/models/msg";
import {UserInMessage} from "../../shared/types/msg";
import eventbus from "../js/eventbus";
import colorClass from "../js/helpers/colorClass";
import type {ClientChan, ClientNetwork, ClientUser} from "../js/types";
import type {ClientChan, ClientNetwork} from "../js/types";
import {useStore} from "../js/store";

type UsernameUser = Partial<UserInMessage> & {
Expand Down
2 changes: 1 addition & 1 deletion client/components/Windows/SearchResults.vue
Expand Up @@ -106,7 +106,7 @@ import type {ClientMessage} from "../../js/types";
import {useStore} from "../../js/store";
import {useRoute, useRouter} from "vue-router";
import {switchToChannel} from "../../js/router";
import {SearchQuery} from "../../../server/plugins/messageStorage/types";
import {SearchQuery} from "../../../shared/types/storage";

export default defineComponent({
name: "SearchResults",
Expand Down
35 changes: 35 additions & 0 deletions client/js/chan.ts
@@ -0,0 +1,35 @@
import {ClientChan, ClientMessage} from "./types";
import {SharedNetworkChan} from "../../shared/types/network";
import {SharedMsg} from "../../shared/types/msg";

export function toClientChan(shared: SharedNetworkChan): ClientChan {
const history: string[] = [""].concat(
shared.messages
.filter((m) => m.self && m.text && m.type === "message")
// TS is too stupid to see the nil guard on filter... so we monkey patch it
.map((m): string => (m.text ? m.text : ""))
.reverse()
.slice(0, 99)
);
// filter the unused vars
const {messages, totalMessages: _, ...props} = shared;
const channel: ClientChan = {
...props,
editTopic: false,
pendingMessage: "",
inputHistoryPosition: 0,
historyLoading: false,
scrolledToBottom: true,
users: [],
usersOutdated: shared.type === "channel" ? true : false,
moreHistoryAvailable: shared.totalMessages > shared.messages.length,
inputHistory: history,
messages: sharedMsgToClientMsg(messages),
};
return channel;
}

function sharedMsgToClientMsg(shared: SharedMsg[]): ClientMessage[] {
// TODO: this is a stub for now, we will want to populate client specific stuff here
return shared;
}
2 changes: 1 addition & 1 deletion client/js/commands/collapse.ts
Expand Up @@ -11,7 +11,7 @@ function input() {
for (const message of store.state.activeChannel.channel.messages) {
let toggled = false;

for (const preview of message.previews) {
for (const preview of message.previews || []) {
if (preview.shown) {
preview.shown = false;
toggled = true;
Expand Down
2 changes: 1 addition & 1 deletion client/js/commands/expand.ts
Expand Up @@ -11,7 +11,7 @@ function input() {
for (const message of store.state.activeChannel.channel.messages) {
let toggled = false;

for (const preview of message.previews) {
for (const preview of message.previews || []) {
if (!preview.shown) {
preview.shown = true;
toggled = true;
Expand Down