yumush
Clone
https://git.tahinli.com/Tahinli/yumush.git
0 watching·0 forks·Rust·AGPL-3.0·6.8 MiB·27ceb05·Tahinli·8 hours ago·399 commits
| 1 | use bitcode::{Decode, DecodeOwned, Encode}; |
| 2 | |
| 3 | use crate::{ |
| 4 | constant::{MAXIMUM_AVATAR_BYTES, MAXIMUM_MESSAGE_LENGTH}, |
| 5 | error::Error, |
| 6 | model::Hue, |
| 7 | model::{ |
| 8 | Account, AdminActionKind, AdminLogEntry, AttachmentInfo, BackupInfo, Ban, BanScope, |
| 9 | Community, CommunitySummary, CommunityUsage, DayStat, Edit, Friends, Id, Invitation, |
| 10 | InviteCode, LogEntry, Member, Message, MessageHit, Overview, Presence, Rank, ReleaseInfo, |
| 11 | Report, ReportStatus, ServerBan, ServerSettings, SessionInfo, Unread, UpdateClient, Usage, |
| 12 | User, VoiceRoom, |
| 13 | }, |
| 14 | share::{Codec, Kind, Quality, Share, Source}, |
| 15 | stats::Stats, |
| 16 | validate::{ |
| 17 | validate_avatar_size, validate_community_name, validate_forward, validate_new_message, |
| 18 | validate_password, validate_poll, validate_reaction, validate_reason, |
| 19 | validate_server_settings, validate_status, validate_username, |
| 20 | }, |
| 21 | }; |
| 22 | |
| 23 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 24 | pub enum Gate { |
| 25 | Guest, |
| 26 | User, |
| 27 | Builder, |
| 28 | } |
| 29 | |
| 30 | pub trait Call: Encode + DecodeOwned + Send + 'static { |
| 31 | type Reply: Encode + DecodeOwned + Send + 'static; |
| 32 | const GATE: Gate; |
| 33 | |
| 34 | fn into_request(self) -> Request; |
| 35 | |
| 36 | fn validate(&self) -> Result<(), Error> { |
| 37 | Ok(()) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | macro_rules! calls { |
| 42 | ($($name:ident: $gate:ident -> $reply:ty $(, |$c:ident| $check:expr)?;)*) => { |
| 43 | #[derive(Debug, Clone, Encode, Decode)] |
| 44 | pub enum Request { |
| 45 | $($name($name),)* |
| 46 | } |
| 47 | |
| 48 | $( |
| 49 | impl Call for $name { |
| 50 | type Reply = $reply; |
| 51 | const GATE: Gate = Gate::$gate; |
| 52 | |
| 53 | fn into_request(self) -> Request { |
| 54 | Request::$name(self) |
| 55 | } |
| 56 | |
| 57 | $( |
| 58 | fn validate(&self) -> Result<(), Error> { |
| 59 | let $c = self; |
| 60 | $check |
| 61 | } |
| 62 | )? |
| 63 | } |
| 64 | )* |
| 65 | }; |
| 66 | } |
| 67 | |
| 68 | #[derive(Debug, Clone, Encode, Decode)] |
| 69 | pub struct GetSettings; |
| 70 | |
| 71 | #[derive(Debug, Clone, Encode, Decode)] |
| 72 | pub struct GetUser { |
| 73 | pub user_id: Id, |
| 74 | } |
| 75 | |
| 76 | #[derive(Debug, Clone, Encode, Decode)] |
| 77 | pub struct UpdateUser { |
| 78 | pub username: String, |
| 79 | } |
| 80 | |
| 81 | #[derive(Debug, Clone, Encode, Decode)] |
| 82 | pub struct UpdateStatus { |
| 83 | pub status: String, |
| 84 | } |
| 85 | |
| 86 | #[derive(Debug, Clone, Encode, Decode)] |
| 87 | pub struct UpdateHue { |
| 88 | pub hue: Option<Hue>, |
| 89 | } |
| 90 | |
| 91 | #[derive(Debug, Clone, Encode, Decode)] |
| 92 | pub struct UpdatePresence { |
| 93 | pub presence: Presence, |
| 94 | } |
| 95 | |
| 96 | #[derive(Debug, Clone, Encode, Decode)] |
| 97 | pub struct ListPresences; |
| 98 | |
| 99 | #[derive(Debug, Clone, Encode, Decode)] |
| 100 | pub struct UpdateAvatar { |
| 101 | pub image: Vec<u8>, |
| 102 | } |
| 103 | |
| 104 | #[derive(Debug, Clone, Encode, Decode)] |
| 105 | pub struct RemoveAvatar; |
| 106 | |
| 107 | #[derive(Debug, Clone, Encode, Decode)] |
| 108 | pub struct GetAvatar { |
| 109 | pub avatar_id: Id, |
| 110 | } |
| 111 | |
| 112 | #[derive(Debug, Clone, Encode, Decode)] |
| 113 | pub struct ListSessions { |
| 114 | pub user_id: Id, |
| 115 | } |
| 116 | |
| 117 | #[derive(Debug, Clone, Encode, Decode)] |
| 118 | pub struct RevokeSession { |
| 119 | pub user_id: Id, |
| 120 | pub session_id: Id, |
| 121 | } |
| 122 | |
| 123 | #[derive(Debug, Clone, Encode, Decode)] |
| 124 | pub struct CreateCommunity { |
| 125 | pub name: String, |
| 126 | } |
| 127 | |
| 128 | #[derive(Debug, Clone, Encode, Decode)] |
| 129 | pub struct GetCommunity { |
| 130 | pub community_id: Id, |
| 131 | } |
| 132 | |
| 133 | #[derive(Debug, Clone, Encode, Decode)] |
| 134 | pub struct UpdateCommunity { |
| 135 | pub community_id: Id, |
| 136 | pub name: String, |
| 137 | } |
| 138 | |
| 139 | #[derive(Debug, Clone, Encode, Decode)] |
| 140 | pub struct UpdateCommunityAvatar { |
| 141 | pub community_id: Id, |
| 142 | pub image: Option<Vec<u8>>, |
| 143 | } |
| 144 | |
| 145 | #[derive(Debug, Clone, Encode, Decode)] |
| 146 | pub struct DeleteCommunity { |
| 147 | pub community_id: Id, |
| 148 | } |
| 149 | |
| 150 | #[derive(Debug, Clone, Encode, Decode)] |
| 151 | pub struct LeaveCommunity { |
| 152 | pub community_id: Id, |
| 153 | } |
| 154 | |
| 155 | #[derive(Debug, Clone, Encode, Decode)] |
| 156 | pub struct ListCommunities; |
| 157 | |
| 158 | #[derive(Debug, Clone, Encode, Decode)] |
| 159 | pub struct ListMembers { |
| 160 | pub community_id: Id, |
| 161 | } |
| 162 | |
| 163 | #[derive(Debug, Clone, Encode, Decode)] |
| 164 | pub struct Kick { |
| 165 | pub community_id: Id, |
| 166 | pub user_id: Id, |
| 167 | pub reason: Option<String>, |
| 168 | } |
| 169 | |
| 170 | #[derive(Debug, Clone, Encode, Decode)] |
| 171 | pub struct BanMember { |
| 172 | pub community_id: Id, |
| 173 | pub user_id: Id, |
| 174 | pub reason: Option<String>, |
| 175 | } |
| 176 | |
| 177 | #[derive(Debug, Clone, Encode, Decode)] |
| 178 | pub struct Unban { |
| 179 | pub community_id: Id, |
| 180 | pub user_id: Id, |
| 181 | } |
| 182 | |
| 183 | #[derive(Debug, Clone, Encode, Decode)] |
| 184 | pub struct ListBans { |
| 185 | pub community_id: Id, |
| 186 | } |
| 187 | |
| 188 | #[derive(Debug, Clone, Encode, Decode)] |
| 189 | pub struct SetRank { |
| 190 | pub community_id: Id, |
| 191 | pub user_id: Id, |
| 192 | pub rank: Rank, |
| 193 | } |
| 194 | |
| 195 | #[derive(Debug, Clone, Encode, Decode)] |
| 196 | pub struct ListLogs { |
| 197 | pub community_id: Id, |
| 198 | } |
| 199 | |
| 200 | #[derive(Debug, Clone, Encode, Decode)] |
| 201 | pub struct CreateMessage { |
| 202 | pub community_id: Id, |
| 203 | pub body: String, |
| 204 | pub attachments: Vec<Id>, |
| 205 | pub reply_to: Option<Id>, |
| 206 | } |
| 207 | |
| 208 | #[derive(Debug, Clone, Encode, Decode)] |
| 209 | pub struct ForwardMessages { |
| 210 | pub message_ids: Vec<Id>, |
| 211 | pub community_id: Id, |
| 212 | pub snippet: bool, |
| 213 | } |
| 214 | |
| 215 | #[derive(Debug, Clone, Encode, Decode)] |
| 216 | pub struct UpdateMessage { |
| 217 | pub message_id: Id, |
| 218 | pub body: String, |
| 219 | } |
| 220 | |
| 221 | #[derive(Debug, Clone, Encode, Decode)] |
| 222 | pub struct DeleteMessage { |
| 223 | pub message_id: Id, |
| 224 | } |
| 225 | |
| 226 | #[derive(Debug, Clone, Encode, Decode)] |
| 227 | pub struct ListEdits { |
| 228 | pub message_id: Id, |
| 229 | } |
| 230 | |
| 231 | #[derive(Debug, Clone, Encode, Decode)] |
| 232 | pub struct CreatePoll { |
| 233 | pub community_id: Id, |
| 234 | pub question: String, |
| 235 | pub options: Vec<String>, |
| 236 | pub multiple: bool, |
| 237 | pub public: bool, |
| 238 | pub duration: Option<u32>, |
| 239 | } |
| 240 | |
| 241 | #[derive(Debug, Clone, Encode, Decode)] |
| 242 | pub struct Vote { |
| 243 | pub message_id: Id, |
| 244 | pub positions: Vec<u32>, |
| 245 | } |
| 246 | |
| 247 | #[derive(Debug, Clone, Encode, Decode)] |
| 248 | pub struct ClosePoll { |
| 249 | pub message_id: Id, |
| 250 | } |
| 251 | |
| 252 | #[derive(Debug, Clone, Encode, Decode)] |
| 253 | pub struct MyVotes { |
| 254 | pub message_id: Id, |
| 255 | } |
| 256 | |
| 257 | #[derive(Debug, Clone, Encode, Decode)] |
| 258 | pub struct React { |
| 259 | pub message_id: Id, |
| 260 | pub emoji: String, |
| 261 | } |
| 262 | |
| 263 | #[derive(Debug, Clone, Encode, Decode)] |
| 264 | pub struct Pin { |
| 265 | pub message_id: Id, |
| 266 | pub pinned: bool, |
| 267 | } |
| 268 | |
| 269 | #[derive(Debug, Clone, Encode, Decode)] |
| 270 | pub struct ListPins { |
| 271 | pub community_id: Id, |
| 272 | } |
| 273 | |
| 274 | #[derive(Debug, Clone, Encode, Decode)] |
| 275 | pub struct ListMessages { |
| 276 | pub community_id: Id, |
| 277 | pub before: Option<Id>, |
| 278 | } |
| 279 | |
| 280 | #[derive(Debug, Clone, Encode, Decode)] |
| 281 | pub struct ListUnreads; |
| 282 | |
| 283 | #[derive(Debug, Clone, Encode, Decode)] |
| 284 | pub struct MarkRead { |
| 285 | pub community_id: Id, |
| 286 | pub message_id: Id, |
| 287 | } |
| 288 | |
| 289 | #[derive(Debug, Clone, Encode, Decode)] |
| 290 | pub struct Typing { |
| 291 | pub community_id: Id, |
| 292 | } |
| 293 | |
| 294 | #[derive(Debug, Clone, Encode, Decode)] |
| 295 | pub struct FindUser { |
| 296 | pub username: String, |
| 297 | } |
| 298 | |
| 299 | #[derive(Debug, Clone, Encode, Decode)] |
| 300 | pub struct OpenDirect { |
| 301 | pub user_id: Id, |
| 302 | } |
| 303 | |
| 304 | #[derive(Debug, Clone, Encode, Decode)] |
| 305 | pub struct OpenNotes; |
| 306 | |
| 307 | #[derive(Debug, Clone, Encode, Decode)] |
| 308 | pub struct ListFriends; |
| 309 | |
| 310 | #[derive(Debug, Clone, Encode, Decode)] |
| 311 | pub struct AddFriend { |
| 312 | pub user_id: Id, |
| 313 | } |
| 314 | |
| 315 | #[derive(Debug, Clone, Encode, Decode)] |
| 316 | pub struct AcceptFriend { |
| 317 | pub user_id: Id, |
| 318 | } |
| 319 | |
| 320 | #[derive(Debug, Clone, Encode, Decode)] |
| 321 | pub struct RemoveFriend { |
| 322 | pub user_id: Id, |
| 323 | } |
| 324 | |
| 325 | #[derive(Debug, Clone, Encode, Decode)] |
| 326 | pub struct Invite { |
| 327 | pub community_id: Id, |
| 328 | pub user_id: Id, |
| 329 | } |
| 330 | |
| 331 | #[derive(Debug, Clone, Encode, Decode)] |
| 332 | pub struct ListInvitations; |
| 333 | |
| 334 | #[derive(Debug, Clone, Encode, Decode)] |
| 335 | pub struct AcceptInvitation { |
| 336 | pub community_id: Id, |
| 337 | } |
| 338 | |
| 339 | #[derive(Debug, Clone, Encode, Decode)] |
| 340 | pub struct DeclineInvitation { |
| 341 | pub community_id: Id, |
| 342 | } |
| 343 | |
| 344 | #[derive(Debug, Clone, Encode, Decode)] |
| 345 | pub struct ReportMessage { |
| 346 | pub message_id: Id, |
| 347 | pub reason: String, |
| 348 | } |
| 349 | |
| 350 | #[derive(Debug, Clone, Encode, Decode)] |
| 351 | pub struct ReportUser { |
| 352 | pub user_id: Id, |
| 353 | pub reason: String, |
| 354 | } |
| 355 | |
| 356 | #[derive(Debug, Clone, Encode, Decode)] |
| 357 | pub struct ListReports { |
| 358 | pub status: Option<ReportStatus>, |
| 359 | } |
| 360 | |
| 361 | #[derive(Debug, Clone, Encode, Decode)] |
| 362 | pub struct HandleReport { |
| 363 | pub report_id: Id, |
| 364 | pub status: ReportStatus, |
| 365 | } |
| 366 | |
| 367 | #[derive(Debug, Clone, Encode, Decode)] |
| 368 | pub struct JoinVoice { |
| 369 | pub community_id: Id, |
| 370 | } |
| 371 | |
| 372 | #[derive(Debug, Clone, Encode, Decode)] |
| 373 | pub struct LeaveVoice; |
| 374 | |
| 375 | #[derive(Debug, Clone, Encode, Decode)] |
| 376 | pub struct StartShare { |
| 377 | pub kind: Kind, |
| 378 | pub source: Source, |
| 379 | } |
| 380 | |
| 381 | #[derive(Debug, Clone, Encode, Decode)] |
| 382 | pub struct StopShare { |
| 383 | pub kind: Kind, |
| 384 | } |
| 385 | |
| 386 | #[derive(Debug, Clone, Encode, Decode)] |
| 387 | pub struct ListShares { |
| 388 | pub community_id: Id, |
| 389 | } |
| 390 | |
| 391 | #[derive(Debug, Clone, Encode, Decode)] |
| 392 | pub struct WatchShare { |
| 393 | pub user_id: Id, |
| 394 | pub kind: Kind, |
| 395 | pub quality: Quality, |
| 396 | pub decode: Vec<Codec>, |
| 397 | } |
| 398 | |
| 399 | #[derive(Debug, Clone, Encode, Decode)] |
| 400 | pub struct UnwatchShare { |
| 401 | pub user_id: Id, |
| 402 | pub kind: Kind, |
| 403 | } |
| 404 | |
| 405 | #[derive(Debug, Clone, Encode, Decode)] |
| 406 | pub struct RequestKeyframe { |
| 407 | pub user_id: Id, |
| 408 | pub kind: Kind, |
| 409 | pub recover: bool, |
| 410 | } |
| 411 | |
| 412 | #[derive(Debug, Clone, Encode, Decode)] |
| 413 | pub struct ReportLoss { |
| 414 | pub user_id: Id, |
| 415 | pub kind: Kind, |
| 416 | pub permille: u16, |
| 417 | } |
| 418 | |
| 419 | #[derive(Debug, Clone, Encode, Decode)] |
| 420 | pub struct DeclineCall { |
| 421 | pub community_id: Id, |
| 422 | } |
| 423 | |
| 424 | #[derive(Debug, Clone, Encode, Decode)] |
| 425 | pub struct ListVoiceParticipants { |
| 426 | pub community_id: Id, |
| 427 | } |
| 428 | |
| 429 | #[derive(Debug, Clone, Encode, Decode)] |
| 430 | pub struct ListVoiceRooms; |
| 431 | |
| 432 | #[derive(Debug, Clone, Encode, Decode)] |
| 433 | pub struct KickFromVoice { |
| 434 | pub user_id: Id, |
| 435 | } |
| 436 | |
| 437 | #[derive(Debug, Clone, Encode, Decode)] |
| 438 | pub struct ServerMute { |
| 439 | pub user_id: Id, |
| 440 | pub muted: bool, |
| 441 | } |
| 442 | |
| 443 | #[derive(Debug, Clone, Encode, Decode)] |
| 444 | pub struct Register { |
| 445 | pub username: String, |
| 446 | pub password: String, |
| 447 | pub invite: Option<String>, |
| 448 | } |
| 449 | |
| 450 | #[derive(Debug, Clone, Encode, Decode)] |
| 451 | pub struct Login { |
| 452 | pub username: String, |
| 453 | pub password: String, |
| 454 | } |
| 455 | |
| 456 | #[derive(Debug, Clone, Encode, Decode)] |
| 457 | pub struct Logout; |
| 458 | |
| 459 | #[derive(Debug, Clone, Encode, Decode)] |
| 460 | pub struct DeleteUser { |
| 461 | pub user_id: Id, |
| 462 | } |
| 463 | |
| 464 | #[derive(Debug, Clone, Encode, Decode)] |
| 465 | pub struct WatchCommunity { |
| 466 | pub community_id: Option<Id>, |
| 467 | } |
| 468 | |
| 469 | #[derive(Debug, Clone, Encode, Decode)] |
| 470 | pub struct ListUsers; |
| 471 | |
| 472 | #[derive(Debug, Clone, Encode, Decode)] |
| 473 | pub struct ListUserFriends { |
| 474 | pub user_id: Id, |
| 475 | } |
| 476 | |
| 477 | #[derive(Debug, Clone, Encode, Decode)] |
| 478 | pub struct ListAdminLogs { |
| 479 | pub actor_id: Option<Id>, |
| 480 | pub target_id: Option<Id>, |
| 481 | pub action: Option<AdminActionKind>, |
| 482 | pub after_ms: Option<u64>, |
| 483 | pub before_ms: Option<u64>, |
| 484 | } |
| 485 | |
| 486 | #[derive(Debug, Clone, Encode, Decode)] |
| 487 | pub struct GetOverview; |
| 488 | |
| 489 | #[derive(Debug, Clone, Encode, Decode)] |
| 490 | pub struct SuspendUser { |
| 491 | pub user_id: Id, |
| 492 | pub suspended: bool, |
| 493 | } |
| 494 | |
| 495 | #[derive(Debug, Clone, Encode, Decode)] |
| 496 | pub struct RevokeSessions { |
| 497 | pub user_id: Id, |
| 498 | } |
| 499 | |
| 500 | #[derive(Debug, Clone, Encode, Decode)] |
| 501 | pub struct ResetPassword { |
| 502 | pub user_id: Id, |
| 503 | pub password: String, |
| 504 | } |
| 505 | |
| 506 | #[derive(Debug, Clone, Encode, Decode)] |
| 507 | pub struct ClearProfile { |
| 508 | pub user_id: Id, |
| 509 | } |
| 510 | |
| 511 | #[derive(Debug, Clone, Encode, Decode)] |
| 512 | pub struct ListAllCommunities; |
| 513 | |
| 514 | #[derive(Debug, Clone, Encode, Decode)] |
| 515 | pub struct TransferOwnership { |
| 516 | pub community_id: Id, |
| 517 | pub user_id: Id, |
| 518 | } |
| 519 | |
| 520 | #[derive(Debug, Clone, Encode, Decode)] |
| 521 | pub struct UpdateServerSettings { |
| 522 | pub settings: ServerSettings, |
| 523 | } |
| 524 | |
| 525 | #[derive(Debug, Clone, Encode, Decode)] |
| 526 | pub struct CreateUser { |
| 527 | pub username: String, |
| 528 | pub password: String, |
| 529 | } |
| 530 | |
| 531 | #[derive(Debug, Clone, Encode, Decode)] |
| 532 | pub struct RenameUser { |
| 533 | pub user_id: Id, |
| 534 | pub username: String, |
| 535 | } |
| 536 | |
| 537 | #[derive(Debug, Clone, Encode, Decode)] |
| 538 | pub struct TimeoutUser { |
| 539 | pub user_id: Id, |
| 540 | pub minutes: u32, |
| 541 | } |
| 542 | |
| 543 | #[derive(Debug, Clone, Encode, Decode)] |
| 544 | pub struct BanUser { |
| 545 | pub user_id: Id, |
| 546 | pub reason: Option<String>, |
| 547 | pub scope: BanScope, |
| 548 | } |
| 549 | |
| 550 | #[derive(Debug, Clone, Encode, Decode)] |
| 551 | pub struct ListServerBans; |
| 552 | |
| 553 | #[derive(Debug, Clone, Encode, Decode)] |
| 554 | pub struct RemoveServerBan { |
| 555 | pub id: Id, |
| 556 | } |
| 557 | |
| 558 | #[derive(Debug, Clone, Encode, Decode)] |
| 559 | pub struct CreateInviteCode { |
| 560 | pub uses: u32, |
| 561 | pub hours: Option<u32>, |
| 562 | } |
| 563 | |
| 564 | #[derive(Debug, Clone, Encode, Decode)] |
| 565 | pub struct ListInviteCodes; |
| 566 | |
| 567 | #[derive(Debug, Clone, Encode, Decode)] |
| 568 | pub struct DeleteInviteCode { |
| 569 | pub code: String, |
| 570 | } |
| 571 | |
| 572 | #[derive(Debug, Clone, Encode, Decode)] |
| 573 | pub struct SearchMessages { |
| 574 | pub text: Option<String>, |
| 575 | pub user_id: Option<Id>, |
| 576 | pub community_id: Option<Id>, |
| 577 | pub after_ms: Option<u64>, |
| 578 | pub before_ms: Option<u64>, |
| 579 | } |
| 580 | |
| 581 | #[derive(Debug, Clone, Encode, Decode)] |
| 582 | pub struct SearchCommunity { |
| 583 | pub community_id: Id, |
| 584 | pub text: String, |
| 585 | } |
| 586 | |
| 587 | #[derive(Debug, Clone, Encode, Decode)] |
| 588 | pub struct PurgeUser { |
| 589 | pub user_id: Id, |
| 590 | } |
| 591 | |
| 592 | #[derive(Debug, Clone, Encode, Decode)] |
| 593 | pub struct SetCommunityVoice { |
| 594 | pub community_id: Id, |
| 595 | pub enabled: bool, |
| 596 | } |
| 597 | |
| 598 | #[derive(Debug, Clone, Encode, Decode)] |
| 599 | pub struct ListAttachments { |
| 600 | pub user_id: Option<Id>, |
| 601 | pub community_id: Option<Id>, |
| 602 | } |
| 603 | |
| 604 | #[derive(Debug, Clone, Encode, Decode)] |
| 605 | pub struct DeleteAttachment { |
| 606 | pub attachment_id: Id, |
| 607 | } |
| 608 | |
| 609 | #[derive(Debug, Clone, Encode, Decode)] |
| 610 | pub struct GetStorageUsage; |
| 611 | |
| 612 | #[derive(Debug, Clone, Encode, Decode)] |
| 613 | pub struct GetDailyStats { |
| 614 | pub days: u32, |
| 615 | } |
| 616 | |
| 617 | #[derive(Debug, Clone, Encode, Decode)] |
| 618 | pub struct SetGhost { |
| 619 | pub enabled: bool, |
| 620 | } |
| 621 | |
| 622 | #[derive(Debug, Clone, Encode, Decode)] |
| 623 | pub struct CreateBackup; |
| 624 | |
| 625 | #[derive(Debug, Clone, Encode, Decode)] |
| 626 | pub struct ListBackups; |
| 627 | |
| 628 | #[derive(Debug, Clone, Encode, Decode)] |
| 629 | pub struct ListReleases; |
| 630 | |
| 631 | #[derive(Debug, Clone, Encode, Decode)] |
| 632 | pub struct ListUpdateClients { |
| 633 | pub user_id: Id, |
| 634 | } |
| 635 | |
| 636 | #[derive(Debug, Clone, Encode, Decode)] |
| 637 | pub struct PublishRelease { |
| 638 | pub files: Vec<crate::update::Sha>, |
| 639 | pub required: bool, |
| 640 | } |
| 641 | |
| 642 | #[derive(Debug, Clone, Encode, Decode)] |
| 643 | pub struct SetReleaseRequired { |
| 644 | pub seq: u64, |
| 645 | pub required: bool, |
| 646 | } |
| 647 | |
| 648 | #[derive(Debug, Clone, Encode, Decode)] |
| 649 | pub struct FollowStats { |
| 650 | pub user_id: Option<Id>, |
| 651 | } |
| 652 | |
| 653 | #[derive(Debug, Clone, Encode, Decode)] |
| 654 | pub struct GetServerStats; |
| 655 | |
| 656 | #[derive(Debug, Clone, Encode, Decode)] |
| 657 | pub struct RestartServer; |
| 658 | |
| 659 | #[derive(Debug, Clone, Encode, Decode)] |
| 660 | pub struct PushStats { |
| 661 | pub stats: Stats, |
| 662 | } |
| 663 | |
| 664 | #[derive(Debug, Clone, Encode, Decode)] |
| 665 | pub struct DeleteBackup { |
| 666 | pub name: String, |
| 667 | } |
| 668 | |
| 669 | #[derive(Debug, Clone, Encode, Decode)] |
| 670 | pub struct Session { |
| 671 | pub user: User, |
| 672 | pub token: String, |
| 673 | } |
| 674 | |
| 675 | #[derive(Debug, Clone, Encode, Decode)] |
| 676 | pub struct StorageUsage { |
| 677 | pub users: Vec<Usage>, |
| 678 | pub communities: Vec<CommunityUsage>, |
| 679 | } |
| 680 | |
| 681 | calls! { |
| 682 | GetSettings: Guest -> ServerSettings; |
| 683 | GetUser: User -> User; |
| 684 | UpdateUser: User -> User, |c| validate_username(&c.username); |
| 685 | UpdateStatus: User -> User, |c| validate_status(&c.status); |
| 686 | UpdateHue: User -> User; |
| 687 | UpdatePresence: User -> (); |
| 688 | ListPresences: User -> Vec<(Id, Presence)>; |
| 689 | UpdateAvatar: User -> User, |c| validate_avatar_size(&c.image, MAXIMUM_AVATAR_BYTES as u64); |
| 690 | RemoveAvatar: User -> User; |
| 691 | GetAvatar: User -> Vec<u8>; |
| 692 | ListSessions: User -> Vec<SessionInfo>; |
| 693 | RevokeSession: User -> (); |
| 694 | CreateCommunity: User -> Community, |c| validate_community_name(&c.name); |
| 695 | GetCommunity: User -> Community; |
| 696 | UpdateCommunity: User -> Community, |c| validate_community_name(&c.name); |
| 697 | UpdateCommunityAvatar: User -> Community, |c| c.image.as_deref().map_or(Ok(()), |image| validate_avatar_size(image, MAXIMUM_AVATAR_BYTES as u64)); |
| 698 | DeleteCommunity: User -> (); |
| 699 | LeaveCommunity: User -> (); |
| 700 | ListCommunities: User -> Vec<Community>; |
| 701 | ListMembers: User -> Vec<Member>; |
| 702 | Kick: User -> (), |c| validate_reason(c.reason.as_deref()); |
| 703 | BanMember: User -> (), |c| validate_reason(c.reason.as_deref()); |
| 704 | Unban: User -> (); |
| 705 | ListBans: User -> Vec<Ban>; |
| 706 | SetRank: User -> (); |
| 707 | ListLogs: User -> Vec<LogEntry>; |
| 708 | CreateMessage: User -> Message, |c| validate_new_message(&c.body, c.attachments.len(), MAXIMUM_MESSAGE_LENGTH); |
| 709 | ForwardMessages: User -> Vec<Message>, |c| validate_forward(c.message_ids.len()); |
| 710 | UpdateMessage: User -> Message, |c| validate_new_message(&c.body, 0, MAXIMUM_MESSAGE_LENGTH); |
| 711 | DeleteMessage: User -> (); |
| 712 | ListEdits: User -> Vec<Edit>; |
| 713 | CreatePoll: User -> Message, |c| validate_poll(&c.question, &c.options); |
| 714 | Vote: User -> (); |
| 715 | ClosePoll: User -> (); |
| 716 | MyVotes: User -> Vec<u32>; |
| 717 | React: User -> (), |c| validate_reaction(&c.emoji); |
| 718 | Pin: User -> (); |
| 719 | ListPins: User -> Vec<Message>; |
| 720 | ListMessages: User -> Vec<Message>; |
| 721 | ListUnreads: User -> Vec<Unread>; |
| 722 | MarkRead: User -> (); |
| 723 | Typing: User -> (); |
| 724 | FindUser: User -> User; |
| 725 | OpenDirect: User -> Community; |
| 726 | OpenNotes: User -> Community; |
| 727 | ListFriends: User -> Friends; |
| 728 | AddFriend: User -> (); |
| 729 | AcceptFriend: User -> (); |
| 730 | RemoveFriend: User -> (); |
| 731 | Invite: User -> (); |
| 732 | ListInvitations: User -> Vec<Invitation>; |
| 733 | AcceptInvitation: User -> Community; |
| 734 | DeclineInvitation: User -> (); |
| 735 | ReportMessage: User -> (), |c| validate_reason(Some(&c.reason)); |
| 736 | ReportUser: User -> (), |c| validate_reason(Some(&c.reason)); |
| 737 | ListReports: Builder -> Vec<Report>; |
| 738 | HandleReport: User -> (); |
| 739 | JoinVoice: User -> Vec<Id>; |
| 740 | LeaveVoice: User -> (); |
| 741 | StartShare: User -> (); |
| 742 | StopShare: User -> (); |
| 743 | ListShares: User -> Vec<Share>; |
| 744 | WatchShare: User -> (); |
| 745 | UnwatchShare: User -> (); |
| 746 | RequestKeyframe: User -> (); |
| 747 | ReportLoss: User -> (); |
| 748 | DeclineCall: User -> (); |
| 749 | ListVoiceParticipants: User -> Vec<Id>; |
| 750 | ListVoiceRooms: Builder -> Vec<VoiceRoom>; |
| 751 | KickFromVoice: User -> (); |
| 752 | ServerMute: User -> (); |
| 753 | Register: Guest -> Session, |c| validate_username(&c.username).and(validate_password(&c.password)); |
| 754 | Login: Guest -> Session, |c| validate_password(&c.password); |
| 755 | Logout: User -> (); |
| 756 | DeleteUser: User -> (); |
| 757 | WatchCommunity: User -> (); |
| 758 | ListUsers: Builder -> Vec<Account>; |
| 759 | ListAdminLogs: Builder -> Vec<AdminLogEntry>; |
| 760 | ListUserFriends: Builder -> Vec<User>; |
| 761 | GetOverview: Builder -> Overview; |
| 762 | SuspendUser: User -> (); |
| 763 | RevokeSessions: User -> (); |
| 764 | ResetPassword: User -> (), |c| validate_password(&c.password); |
| 765 | ClearProfile: User -> User; |
| 766 | ListAllCommunities: Builder -> Vec<CommunitySummary>; |
| 767 | TransferOwnership: User -> (); |
| 768 | UpdateServerSettings: Builder -> ServerSettings, |c| validate_server_settings(&c.settings); |
| 769 | CreateUser: Builder -> User, |c| validate_username(&c.username).and(validate_password(&c.password)); |
| 770 | RenameUser: User -> User, |c| validate_username(&c.username); |
| 771 | TimeoutUser: User -> (); |
| 772 | BanUser: User -> (), |c| validate_reason(c.reason.as_deref()); |
| 773 | ListServerBans: Builder -> Vec<ServerBan>; |
| 774 | RemoveServerBan: Builder -> (); |
| 775 | CreateInviteCode: User -> InviteCode; |
| 776 | ListInviteCodes: Builder -> Vec<InviteCode>; |
| 777 | DeleteInviteCode: Builder -> (); |
| 778 | SearchMessages: Builder -> Vec<MessageHit>; |
| 779 | SearchCommunity: User -> Vec<MessageHit>; |
| 780 | PurgeUser: User -> (); |
| 781 | SetCommunityVoice: User -> Community; |
| 782 | ListAttachments: Builder -> Vec<AttachmentInfo>; |
| 783 | DeleteAttachment: Builder -> (); |
| 784 | GetStorageUsage: Builder -> StorageUsage; |
| 785 | GetDailyStats: Builder -> Vec<DayStat>; |
| 786 | SetGhost: Builder -> (); |
| 787 | CreateBackup: Builder -> BackupInfo; |
| 788 | ListBackups: Builder -> Vec<BackupInfo>; |
| 789 | DeleteBackup: Builder -> (); |
| 790 | ListReleases: Builder -> Vec<ReleaseInfo>; |
| 791 | ListUpdateClients: Builder -> Vec<UpdateClient>; |
| 792 | PublishRelease: Builder -> ReleaseInfo; |
| 793 | SetReleaseRequired: Builder -> (); |
| 794 | FollowStats: Builder -> Option<Stats>; |
| 795 | PushStats: User -> (); |
| 796 | GetServerStats: Builder -> Stats; |
| 797 | RestartServer: Builder -> (); |
| 798 | } |