├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── cmd
└── gen
│ ├── extractor
│ └── extractor.go
│ ├── generator
│ ├── routes.go
│ └── struct.go
│ └── main.go
├── examples
├── basic
│ └── main.go
├── comments
│ └── main.go
└── posts
│ └── main.go
├── go.mod
├── go.sum
├── lemmy.go
├── optional.go
├── routes.gen.go
└── types.gen.go
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | liberapay: Elara6331
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /test
2 | /gen
3 | /lemmy/
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type 'show c' for details.
659 |
660 | The hypothetical commands 'show w' and 'show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Go-Lemmy
2 |
3 | [](https://pkg.go.dev/go.elara.ws/go-lemmy)
4 |
5 | Go bindings to the [Lemmy](https://join-lemmy.org) API, automatically generated from Lemmy's source code using the generator in [cmd/gen](cmd/gen).
6 |
7 | ### Examples
8 |
9 | Examples can be found in the [examples](examples) directory.
10 |
11 | ### How to generate
12 |
13 | First, clone the [lemmy-js-client](https://github.com/LemmyNet/lemmy-js-client) repo at whatever version you need:
14 |
15 | ```bash
16 | git clone https://github.com/LemmyNet/lemmy-js-client -b 0.18.3
17 | ```
18 |
19 | Inside it, build the JSON docs file:
20 |
21 | ```bash
22 | npm run docs -- --json docs.json
23 | ```
24 |
25 | Next, build the generator:
26 |
27 | ```bash
28 | go build ./cmd/gen
29 | ```
30 |
31 | Remove all the existing generated code:
32 |
33 | ```bash
34 | rm **/*.gen.go
35 | ```
36 |
37 | Execute the generator:
38 |
39 | ```bash
40 | ./gen -json-file -out-dir .
41 | ```
42 |
43 | And that's it! Your generated code should be ready for use.
44 |
--------------------------------------------------------------------------------
/cmd/gen/extractor/extractor.go:
--------------------------------------------------------------------------------
1 | package extractor
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "strings"
7 |
8 | "github.com/tidwall/gjson"
9 | )
10 |
11 | type Route struct {
12 | Name string
13 | Summary string
14 | Method string
15 | Path string
16 | ParamsName string
17 | ReturnName string
18 | }
19 |
20 | type Struct struct {
21 | Name string
22 | Fields []Field
23 | UnionNames []string
24 | }
25 |
26 | type Field struct {
27 | Name string
28 | IsArray bool
29 | IsOptional bool
30 | Type string
31 | }
32 |
33 | type Extractor struct {
34 | root gjson.Result
35 | }
36 |
37 | // New parses the file at path and returns an extractor with its contents.
38 | func New(path string) (*Extractor, error) {
39 | data, err := os.ReadFile(path)
40 | if err != nil {
41 | return nil, err
42 | }
43 |
44 | return &Extractor{gjson.ParseBytes(data)}, nil
45 | }
46 |
47 | // Extract reads the JSON document and extracts all the routes and structs from it.
48 | func (e *Extractor) Extract() ([]Route, []Struct) {
49 | structs := map[int64]Struct{}
50 | var out []Route
51 |
52 | // Get all the routes in the JSON document
53 | routes := e.root.Get("children.#.children.#(kind==2048)#|@flatten")
54 |
55 | for _, route := range routes.Array() {
56 | name := route.Get("name").String()
57 | signature := route.Get(`signatures.0`)
58 |
59 | // Get the code part of the route's summary.
60 | // This will contain the HTTP method and path.
61 | httpInfo := signature.Get(`comment.summary.#(kind=="code").text`).String()
62 | if !strings.HasPrefix(httpInfo, "`HTTP") {
63 | continue
64 | }
65 | method, path := parseHTTPInfo(httpInfo)
66 |
67 | summary := strings.TrimSpace(signature.Get(`comment.summary.#(kind=="text").text`).String())
68 | if summary == "" {
69 | continue
70 | }
71 |
72 | // Get the ID and name of the type this function accepts
73 | paramsID := signature.Get("parameters.0.type.target").Int()
74 | paramsName := signature.Get("parameters.0.type.name").String()
75 |
76 | // Get the ID and name of the type this function returns
77 | returnID := signature.Get("type.typeArguments.0.target").Int()
78 | returnName := signature.Get("type.typeArguments.0.name").String()
79 |
80 | anyType := false
81 | if returnName == "any" {
82 | anyType = true
83 | }
84 |
85 | // Get the referenced structs from the JSON document
86 | e.getStructs([]int64{paramsID, returnID}, structs)
87 |
88 | // If the parameters struct contains no fields or union names
89 | if len(structs[paramsID].Fields) == 0 && len(structs[paramsID].UnionNames) == 0 {
90 | // Delete the params struct from the structs map
91 | // to make sure it doesn't get generated
92 | delete(structs, paramsID)
93 |
94 | // Set paramsName to an empty string to signify that this route
95 | // has no input parameters.
96 | paramsName = ""
97 | }
98 |
99 | // If the return struct contains no fields or union names
100 | if len(structs[returnID].Fields) == 0 && len(structs[returnID].UnionNames) == 0 {
101 | // Delete the return struct from the structs map
102 | // to make sure it doesn't get generated
103 | delete(structs, returnID)
104 |
105 | // Set paramsName to an empty string to signify that this route
106 | // has no return value.
107 | returnName = ""
108 | }
109 |
110 | if anyType {
111 | returnName = "map[string]any"
112 | }
113 |
114 | out = append(out, Route{
115 | Name: name,
116 | Summary: summary,
117 | Method: method,
118 | Path: path,
119 | ParamsName: paramsName,
120 | ReturnName: returnName,
121 | })
122 | }
123 | return out, getStructSlice(structs)
124 | }
125 |
126 | func (e *Extractor) getStructs(ids []int64, structs map[int64]Struct) {
127 | for _, id := range ids {
128 | if _, ok := structs[id]; ok {
129 | continue
130 | }
131 |
132 | // Get the struct with the given ID from the JSON document
133 | jstruct := e.root.Get(fmt.Sprintf("children.#(id==%d)", id))
134 | if !jstruct.Exists() {
135 | continue
136 | }
137 |
138 | name := jstruct.Get("name").String()
139 |
140 | if jstruct.Get("type.type").String() == "union" {
141 | structs[id] = Struct{
142 | Name: name,
143 | UnionNames: e.unionNames(jstruct),
144 | }
145 | } else {
146 | fields, newIDs := e.fields(jstruct)
147 |
148 | structs[id] = Struct{
149 | Name: name,
150 | Fields: fields,
151 | }
152 |
153 | // Recursively get any structs referenced by this one
154 | e.getStructs(newIDs, structs)
155 | }
156 |
157 | }
158 | }
159 |
160 | // unionNames gets all the names of union type members
161 | func (e *Extractor) unionNames(jstruct gjson.Result) []string {
162 | jnames := jstruct.Get("type.types").Array()
163 | out := make([]string, len(jnames))
164 | for i, name := range jnames {
165 | out[i] = name.Get("value").String()
166 | }
167 | return out
168 | }
169 |
170 | // fields gets all the fields in a given struct from the JSON document.
171 | // It returns the fields and the IDs of any types they referenced.
172 | func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) {
173 | var fields []Field
174 | var ids []int64
175 | jfields := jstruct.Get("children").Array()
176 | for _, jfield := range jfields {
177 | var field Field
178 |
179 | field.Name = jfield.Get("name").String()
180 | field.IsOptional = jfield.Get("flags.isOptional").Bool()
181 |
182 | if jfield.Get("type.type").String() == "array" {
183 | field.IsArray = true
184 | field.Type = jfield.Get("type.elementType.name").String()
185 |
186 | switch jfield.Get("type.elementType.type").String() {
187 | case "reference":
188 | // If this field is referencing another type, add that type's id
189 | // to the ids slice.
190 | ids = append(ids, jfield.Get("type.elementType.target").Int())
191 | case "union":
192 | // Convert unions to strings
193 | field.Type = "string"
194 | }
195 | } else {
196 | field.Type = jfield.Get("type.name").String()
197 |
198 | switch jfield.Get("type.type").String() {
199 | case "reference":
200 | // If this field is referencing another type, add that type's id
201 | // to the ids slice.
202 | ids = append(ids, jfield.Get("type.target").Int())
203 | case "union":
204 | // Convert unions to strings
205 | field.Type = "string"
206 | }
207 | }
208 |
209 | fields = append(fields, field)
210 | }
211 | return fields, ids
212 | }
213 |
214 | // parseHTTPInfo parses the string from a route's summary,
215 | // and returns the method and path it uses
216 | func parseHTTPInfo(httpInfo string) (method, path string) {
217 | httpInfo = strings.Trim(httpInfo, "`")
218 | method, path, _ = strings.Cut(httpInfo, " ")
219 | method = strings.TrimPrefix(method, "HTTP.")
220 | method = strings.ToUpper(method)
221 | return method, path
222 | }
223 |
224 | // getStructSlice returns all the structs in a map
225 | func getStructSlice(m map[int64]Struct) []Struct {
226 | out := make([]Struct, len(m))
227 | i := 0
228 | for _, s := range m {
229 | out[i] = s
230 | i++
231 | }
232 | return out
233 | }
234 |
--------------------------------------------------------------------------------
/cmd/gen/generator/routes.go:
--------------------------------------------------------------------------------
1 | package generator
2 |
3 | import (
4 | "io"
5 | "strings"
6 |
7 | "github.com/dave/jennifer/jen"
8 | "go.elara.ws/go-lemmy/cmd/gen/extractor"
9 | )
10 |
11 | type RoutesGenerator struct {
12 | w io.Writer
13 | PkgName string
14 | }
15 |
16 | func NewRoutes(w io.Writer, pkgName string) *RoutesGenerator {
17 | return &RoutesGenerator{w, pkgName}
18 | }
19 |
20 | func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
21 | f := jen.NewFile(r.PkgName)
22 | f.HeaderComment("Code generated by go.elara.ws/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.")
23 |
24 | for _, r := range routes {
25 | f.Comment(r.Summary)
26 | f.Func().Params(
27 | jen.Id("c").Id("*Client"),
28 | ).Id(transformName(r.Name)).ParamsFunc(func(g *jen.Group) {
29 | g.Id("ctx").Qual("context", "Context")
30 | if r.ParamsName != "" {
31 | g.Id("data").Id(r.ParamsName)
32 | }
33 | }).ParamsFunc(func(g *jen.Group) {
34 | if r.ReturnName == "map[string]any" {
35 | g.Map(jen.String()).Any()
36 | } else if r.ReturnName != "" {
37 | g.Op("*").Id(r.ReturnName)
38 | }
39 |
40 | g.Error()
41 | }).BlockFunc(func(g *jen.Group) {
42 | data := jen.Id("data")
43 | // If there are no parameters, set the data to nil
44 | if r.ParamsName == "" {
45 | data = jen.Nil()
46 | }
47 |
48 | returnName := r.ReturnName
49 | if returnName == "" {
50 | returnName = "emptyResponse"
51 | }
52 |
53 | if returnName == "map[string]any" {
54 | g.Id("resData").Op(":=").Map(jen.String()).Any().Block()
55 | } else {
56 | g.Id("resData").Op(":=").Op("&").Id(returnName).Block()
57 | }
58 |
59 | funcName := "req"
60 | if r.Method == "GET" {
61 | funcName = "getReq"
62 | }
63 |
64 | g.List(jen.Id("res"), jen.Err()).Op(":=").Id("c").Dot(funcName).ParamsFunc(func(g *jen.Group) {
65 | g.Id("ctx")
66 | g.Lit(r.Method)
67 | g.Lit(r.Path)
68 | g.Add(data)
69 |
70 | if returnName == "map[string]any" {
71 | g.Op("&").Id("resData")
72 | } else {
73 | g.Id("resData")
74 | }
75 | })
76 | g.If(jen.Err().Op("!=").Nil()).BlockFunc(func(g *jen.Group) {
77 | if returnName == "emptyResponse" {
78 | g.Return(jen.Err())
79 | } else {
80 | g.Return(jen.Nil(), jen.Err())
81 | }
82 | })
83 |
84 | if r.ReturnName == "map[string]any" {
85 | g.Err().Op("=").Id("resError").Params(jen.Id("res"), jen.Id("NewOptionalNil[string]").Params())
86 | } else {
87 | g.Err().Op("=").Id("resError").Params(jen.Id("res"), jen.Id("resData").Dot("Error"))
88 | }
89 |
90 | g.If(jen.Err().Op("!=").Nil()).BlockFunc(func(g *jen.Group) {
91 | if returnName == "emptyResponse" {
92 | g.Return(jen.Err())
93 | } else {
94 | g.Return(jen.Nil(), jen.Err())
95 | }
96 | })
97 |
98 | if returnName == "emptyResponse" {
99 | g.Return(jen.Nil())
100 | } else {
101 | g.Return(jen.Id("resData"), jen.Nil())
102 | }
103 | })
104 | }
105 |
106 | return f.Render(r.w)
107 | }
108 |
109 | func transformName(s string) string {
110 | s = strings.ToUpper(s[:1]) + s[1:]
111 | s = strings.TrimPrefix(s, "Get")
112 | s = strings.TrimPrefix(s, "List")
113 | return s
114 | }
115 |
--------------------------------------------------------------------------------
/cmd/gen/generator/struct.go:
--------------------------------------------------------------------------------
1 | package generator
2 |
3 | import (
4 | "io"
5 | "strings"
6 | "unicode"
7 |
8 | "github.com/dave/jennifer/jen"
9 | "go.elara.ws/go-lemmy/cmd/gen/extractor"
10 | )
11 |
12 | type StructGenerator struct {
13 | w io.Writer
14 | PkgName string
15 | }
16 |
17 | func NewStruct(w io.Writer, pkgName string) *StructGenerator {
18 | return &StructGenerator{w, pkgName}
19 | }
20 |
21 | func (s *StructGenerator) Generate(items []extractor.Struct) error {
22 | f := jen.NewFile(s.PkgName)
23 | f.HeaderComment("Code generated by go.elara.ws/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.")
24 |
25 | for _, item := range items {
26 | if len(item.UnionNames) > 0 {
27 | f.Type().Id(item.Name).String()
28 |
29 | f.Const().DefsFunc(func(g *jen.Group) {
30 | for _, member := range item.UnionNames {
31 | constName := strings.Replace(item.Name+string(member), " ", "", -1)
32 | g.Id(constName).Id(item.Name).Op("=").Lit(string(member))
33 | }
34 | })
35 | } else {
36 | f.Type().Id(item.Name).StructFunc(func(g *jen.Group) {
37 | for _, field := range item.Fields {
38 | g.Id(transformFieldName(field.Name)).Add(getType(field)).Tag(map[string]string{
39 | "json": field.Name,
40 | "url": field.Name + ",omitempty",
41 | })
42 | }
43 |
44 | if strings.HasSuffix(item.Name, "Response") {
45 | g.Id("Error").Id("Optional").Types(jen.String()).Tag(map[string]string{"json": "error"})
46 | }
47 | })
48 | }
49 | }
50 |
51 | return f.Render(s.w)
52 | }
53 |
54 | func getType(f extractor.Field) jen.Code {
55 | // Some time fields are strings in the JS client,
56 | // use time.Time for those
57 | switch f.Name {
58 | case "published", "updated", "when_":
59 | return jen.Qual("time", "Time")
60 | }
61 |
62 | // Rank types such as hot_rank and hot_rank_active may be floats.
63 | if strings.Contains(f.Name, "rank") {
64 | return jen.Float64()
65 | }
66 |
67 | t := transformType(f.Name, f.Type)
68 | if f.IsArray {
69 | t = "[]" + t
70 | }
71 | if f.IsOptional {
72 | t = "Optional[" + t + "]"
73 | }
74 | return jen.Id(t)
75 | }
76 |
77 | func transformType(name, t string) string {
78 | switch t {
79 | case "number":
80 | return "int64"
81 | case "boolean":
82 | return "bool"
83 | default:
84 | return t
85 | }
86 | }
87 |
88 | func transformFieldName(s string) string {
89 | s = snakeToCamel(s)
90 | s = strings.NewReplacer(
91 | "Id", "ID",
92 | "Url", "URL",
93 | "Nsfw", "NSFW",
94 | "Jwt", "JWT",
95 | "Crud", "CRUD",
96 | "Pm", "PM",
97 | "Totp", "TOTP",
98 | "2fa", "2FA",
99 | "Png", "PNG",
100 | "Uuid", "UUID",
101 | "Wav", "WAV",
102 | ).Replace(s)
103 | return s
104 | }
105 |
106 | func snakeToCamel(s string) string {
107 | sb := &strings.Builder{}
108 | capitalizeNext := true
109 | for _, char := range s {
110 | if char == '_' {
111 | capitalizeNext = true
112 | continue
113 | }
114 |
115 | if capitalizeNext {
116 | sb.WriteRune(unicode.ToUpper(char))
117 | capitalizeNext = false
118 | } else {
119 | sb.WriteRune(char)
120 | }
121 | }
122 | return sb.String()
123 | }
124 |
--------------------------------------------------------------------------------
/cmd/gen/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "os"
6 | "path/filepath"
7 |
8 | "go.elara.ws/go-lemmy/cmd/gen/extractor"
9 | "go.elara.ws/go-lemmy/cmd/gen/generator"
10 | "go.elara.ws/logger"
11 | "go.elara.ws/logger/log"
12 | )
13 |
14 | func init() {
15 | log.Logger = logger.NewPretty(os.Stderr)
16 | }
17 |
18 | func main() {
19 | jsonFile := flag.String("json-file", "lemmy.json", "Path to the JSON file generated from lemmy's docs")
20 | outDir := flag.String("out-dir", "out", "Directory to write output in")
21 | flag.Parse()
22 |
23 | e, err := extractor.New(*jsonFile)
24 | if err != nil {
25 | log.Fatal("Error creating extractor").Err(err).Send()
26 | }
27 |
28 | routes, structs := e.Extract()
29 |
30 | otf, err := os.Create(filepath.Join(*outDir, "types.gen.go"))
31 | if err != nil {
32 | log.Fatal("Error creating types output file").Err(err).Send()
33 | }
34 | defer otf.Close()
35 |
36 | err = generator.NewStruct(otf, "lemmy").Generate(structs)
37 | if err != nil {
38 | log.Fatal("Error generating output routes file").Err(err).Send()
39 | }
40 |
41 | orf, err := os.Create(filepath.Join(*outDir, "routes.gen.go"))
42 | if err != nil {
43 | log.Fatal("Error creating routes output file").Err(err).Send()
44 | }
45 | defer orf.Close()
46 |
47 | err = generator.NewRoutes(orf, "lemmy").Generate(routes)
48 | if err != nil {
49 | log.Fatal("Error generating output routes file").Err(err).Send()
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/examples/basic/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 |
6 | "go.elara.ws/go-lemmy"
7 | )
8 |
9 | func main() {
10 | ctx := context.Background()
11 |
12 | c, err := lemmy.New("https://lemmy.ml")
13 | if err != nil {
14 | panic(err)
15 | }
16 |
17 | err = c.ClientLogin(ctx, lemmy.Login{
18 | UsernameOrEmail: "user@example.com",
19 | Password: `TestPwd`,
20 | })
21 | if err != nil {
22 | panic(err)
23 | }
24 |
25 | _, err = c.SaveUserSettings(ctx, lemmy.SaveUserSettings{
26 | BotAccount: lemmy.NewOptional(true),
27 | })
28 | if err != nil {
29 | panic(err)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/comments/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "log"
6 |
7 | "go.elara.ws/go-lemmy"
8 | )
9 |
10 | func main() {
11 | ctx := context.Background()
12 |
13 | c, err := lemmy.New("https://lemmy.ml")
14 | if err != nil {
15 | panic(err)
16 | }
17 |
18 | err = c.ClientLogin(ctx, lemmy.Login{
19 | UsernameOrEmail: "user@example.com",
20 | Password: `TestPwd`,
21 | })
22 | if err != nil {
23 | panic(err)
24 | }
25 |
26 | cr, err := c.CreateComment(ctx, lemmy.CreateComment{
27 | PostID: 2,
28 | Content: "Hello from go-lemmy!",
29 | })
30 | if err != nil {
31 | panic(err)
32 | }
33 |
34 | cr2, err := c.CreateComment(ctx, lemmy.CreateComment{
35 | PostID: 2,
36 | ParentID: lemmy.NewOptional(cr.CommentView.Comment.ID),
37 | Content: "Reply from go-lemmy",
38 | })
39 | if err != nil {
40 | panic(err)
41 | }
42 |
43 | log.Printf(
44 | "Created comment %d and replied to it with comment %d!\n",
45 | cr.CommentView.Comment.ID,
46 | cr2.CommentView.Comment.ID,
47 | )
48 | }
49 |
--------------------------------------------------------------------------------
/examples/posts/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "log"
6 |
7 | "go.elara.ws/go-lemmy"
8 | )
9 |
10 | func main() {
11 | ctx := context.Background()
12 |
13 | c, err := lemmy.New("https://lemmy.ml")
14 | if err != nil {
15 | panic(err)
16 | }
17 |
18 | // Log in to lemmy.ml
19 | err = c.ClientLogin(ctx, lemmy.Login{
20 | UsernameOrEmail: "user@example.com",
21 | Password: `TestPwd`,
22 | })
23 | if err != nil {
24 | panic(err)
25 | }
26 |
27 | // Get the linux community to get its ID.
28 | gcr, err := c.Community(ctx, lemmy.GetCommunity{
29 | Name: lemmy.NewOptional("linux"),
30 | })
31 | if err != nil {
32 | panic(err)
33 | }
34 |
35 | // Create a Hello World post in the linux community.
36 | pr, err := c.CreatePost(ctx, lemmy.CreatePost{
37 | CommunityID: gcr.CommunityView.Community.ID,
38 | Name: "Hello, World!",
39 | Body: lemmy.NewOptional("This is an example post"),
40 | })
41 |
42 | log.Println("Created post:", pr.PostView.Post.ID)
43 | }
44 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module go.elara.ws/go-lemmy
2 |
3 | go 1.19
4 |
5 | require (
6 | github.com/dave/jennifer v1.6.0
7 | github.com/google/go-querystring v1.1.0
8 | github.com/tidwall/gjson v1.17.0
9 | go.elara.ws/logger v0.0.0-20230421022458-e80700db2090
10 | golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304
11 | )
12 |
13 | require (
14 | github.com/gookit/color v1.5.1 // indirect
15 | github.com/mattn/go-isatty v0.0.14 // indirect
16 | github.com/tidwall/match v1.1.1 // indirect
17 | github.com/tidwall/pretty v1.2.0 // indirect
18 | github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
19 | golang.org/x/sys v0.1.0 // indirect
20 | )
21 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/dave/jennifer v1.6.0 h1:MQ/6emI2xM7wt0tJzJzyUik2Q3Tcn2eE0vtYgh4GPVI=
2 | github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+EgvszgGRnk=
3 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
4 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
6 | github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
7 | github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
8 | github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
9 | github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
10 | github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
11 | github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
12 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
13 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
14 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
15 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
16 | github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
17 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
18 | github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
19 | github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
20 | github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
21 | github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
22 | github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
23 | github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
24 | github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
25 | github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
26 | go.elara.ws/logger v0.0.0-20230421022458-e80700db2090 h1:RVC8XvWo6Yw4HUshqx4TSzuBDScDghafU6QFRJ4xPZg=
27 | go.elara.ws/logger v0.0.0-20230421022458-e80700db2090/go.mod h1:qng49owViqsW5Aey93lwBXONw20oGbJIoLVscB16mPM=
28 | golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304 h1:YUqj+XKtfrn3kXjFIiZ8jwKROD7ioAOOHUuo3ZZ2opc=
29 | golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
30 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
31 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
32 | golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
33 | golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
34 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
35 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
37 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
38 |
--------------------------------------------------------------------------------
/lemmy.go:
--------------------------------------------------------------------------------
1 | package lemmy
2 |
3 | import (
4 | "bytes"
5 | "context"
6 | "encoding/json"
7 | "errors"
8 | "fmt"
9 | "io"
10 | "net/http"
11 | "net/url"
12 |
13 | "github.com/google/go-querystring/query"
14 | )
15 |
16 | // ErrNoToken is an error returned by ClientLogin if the server sends a null or empty token
17 | var ErrNoToken = errors.New("the server didn't provide a token value in its response")
18 |
19 | // Client is a client for Lemmy's HTTP API
20 | type Client struct {
21 | client *http.Client
22 | baseURL *url.URL
23 | Token string
24 | }
25 |
26 | // New creates a new Lemmy client with the default HTTP client.
27 | func New(baseURL string) (*Client, error) {
28 | return NewWithClient(baseURL, http.DefaultClient)
29 | }
30 |
31 | // NewWithClient creates a new Lemmy client with the given HTTP client
32 | func NewWithClient(baseURL string, client *http.Client) (*Client, error) {
33 | u, err := url.Parse(baseURL)
34 | if err != nil {
35 | return nil, err
36 | }
37 | u = u.JoinPath("/api/v3")
38 | return &Client{baseURL: u, client: client}, nil
39 | }
40 |
41 | // ClientLogin logs in to Lemmy by calling the login endpoint, and
42 | // stores the returned token in the Token field for use in future requests.
43 | //
44 | // The Token field can be set manually if you'd like to persist the
45 | // token somewhere.
46 | func (c *Client) ClientLogin(ctx context.Context, data Login) error {
47 | lr, err := c.Login(ctx, data)
48 | if err != nil {
49 | return err
50 | }
51 |
52 | token, ok := lr.JWT.Value()
53 | if !ok || token == "" {
54 | return ErrNoToken
55 | }
56 | c.Token = token
57 | return nil
58 | }
59 |
60 | // req makes a request to the server
61 | func (c *Client) req(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) {
62 | var r io.Reader
63 | if data != nil {
64 | jsonData, err := json.Marshal(data)
65 | if err != nil {
66 | return nil, err
67 | }
68 | r = bytes.NewReader(jsonData)
69 | }
70 |
71 | req, err := http.NewRequestWithContext(
72 | ctx,
73 | method,
74 | c.baseURL.JoinPath(path).String(),
75 | r,
76 | )
77 | if err != nil {
78 | return nil, err
79 | }
80 |
81 | req.Header.Add("Content-Type", "application/json")
82 |
83 | if c.Token != "" {
84 | req.Header.Add("Authorization", "Bearer "+c.Token)
85 | }
86 |
87 | res, err := c.client.Do(req)
88 | if err != nil {
89 | return nil, err
90 | }
91 | defer res.Body.Close()
92 |
93 | err = json.NewDecoder(res.Body).Decode(resp)
94 | if err == io.EOF {
95 | return res, nil
96 | } else if err != nil {
97 | return nil, err
98 | }
99 |
100 | return res, nil
101 | }
102 |
103 | // getReq makes a get request to the Lemmy server.
104 | // It's separate from req() because it uses query
105 | // parameters rather than a JSON request body.
106 | func (c *Client) getReq(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) {
107 | getURL := c.baseURL.JoinPath(path)
108 | if data != nil {
109 | vals, err := query.Values(data)
110 | if err != nil {
111 | return nil, err
112 | }
113 | getURL.RawQuery = vals.Encode()
114 | }
115 |
116 | req, err := http.NewRequestWithContext(
117 | ctx,
118 | method,
119 | getURL.String(),
120 | nil,
121 | )
122 | if err != nil {
123 | return nil, err
124 | }
125 |
126 | if c.Token != "" {
127 | req.Header.Add("Authorization", "Bearer "+c.Token)
128 | }
129 |
130 | res, err := c.client.Do(req)
131 | if err != nil {
132 | return nil, err
133 | }
134 | defer res.Body.Close()
135 |
136 | err = json.NewDecoder(res.Body).Decode(resp)
137 | if err == io.EOF {
138 | return res, nil
139 | } else if err != nil {
140 | return nil, err
141 | }
142 |
143 | return res, nil
144 | }
145 |
146 | // Error represents an error returned by the Lemmy API
147 | type Error struct {
148 | ErrStr string
149 | Code int
150 | }
151 |
152 | func (le Error) Error() string {
153 | if le.ErrStr != "" {
154 | return fmt.Sprintf("%d %s: %s", le.Code, http.StatusText(le.Code), le.ErrStr)
155 | } else {
156 | return fmt.Sprintf("%d %s", le.Code, http.StatusText(le.Code))
157 | }
158 | }
159 |
160 | // emptyResponse is a response without any fields.
161 | // It has an Error field to capture any errors.
162 | type emptyResponse struct {
163 | Error Optional[string] `json:"error"`
164 | }
165 |
166 | // resError checks if the response contains an error, and if so, returns
167 | // a Go error representing it.
168 | func resError(res *http.Response, err Optional[string]) error {
169 | if errstr, ok := err.Value(); ok {
170 | return Error{
171 | Code: res.StatusCode,
172 | ErrStr: errstr,
173 | }
174 | } else if res.StatusCode != http.StatusOK {
175 | return Error{
176 | Code: res.StatusCode,
177 | }
178 | } else {
179 | return nil
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/optional.go:
--------------------------------------------------------------------------------
1 | package lemmy
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | "fmt"
7 | "net/url"
8 | )
9 |
10 | // Optional represents an optional value
11 | type Optional[T any] struct {
12 | value *T
13 | }
14 |
15 | // NewOptional creates an optional with value v
16 | func NewOptional[T any](v T) Optional[T] {
17 | return Optional[T]{value: &v}
18 | }
19 |
20 | // NewOptionalNil creates a new nil optional value
21 | func NewOptionalNil[T any]() Optional[T] {
22 | return Optional[T]{}
23 | }
24 |
25 | // Set sets the value of the optional
26 | func (o Optional[T]) Set(v T) Optional[T] {
27 | o.value = &v
28 | return o
29 | }
30 |
31 | // SetNil sets the optional value to nil
32 | func (o Optional[T]) SetNil() Optional[T] {
33 | o.value = nil
34 | return o
35 | }
36 |
37 | // IsValid returns true if the value of the optional is not nil
38 | func (o Optional[T]) IsValid() bool {
39 | return o.value != nil
40 | }
41 |
42 | // Value returns the value in the optional.
43 | func (o Optional[T]) Value() (T, bool) {
44 | if o.value != nil {
45 | return *o.value, true
46 | }
47 | return *new(T), false
48 | }
49 |
50 | // ValueOr returns the value inside the optional if it exists, or else it returns fallback
51 | func (o Optional[T]) ValueOr(fallback T) T {
52 | if o.value != nil {
53 | return *o.value
54 | }
55 | return fallback
56 | }
57 |
58 | // ValueOrZero returns the value inside the optional if it exists, or else it returns the zero value of T
59 | func (o Optional[T]) ValueOrZero() T {
60 | if o.value != nil {
61 | return *o.value
62 | }
63 | var value T
64 | return value
65 | }
66 |
67 | // MarshalJSON encodes the optional value as JSON
68 | func (o Optional[T]) MarshalJSON() ([]byte, error) {
69 | return json.Marshal(o.value)
70 | }
71 |
72 | // UnmarshalJSON decodes JSON into the optional value
73 | func (o *Optional[T]) UnmarshalJSON(b []byte) error {
74 | if bytes.Equal(b, []byte("null")) {
75 | o.value = nil
76 | return nil
77 | }
78 |
79 | o.value = new(T)
80 | return json.Unmarshal(b, o.value)
81 | }
82 |
83 | // EncodeValues encodes the optional as a URL query parameter
84 | func (o Optional[T]) EncodeValues(key string, v *url.Values) error {
85 | s := o.String()
86 | if s != "" {
87 | v.Set(key, s)
88 | }
89 | return nil
90 | }
91 |
92 | // String returns the string representation of the optional value
93 | func (o Optional[T]) String() string {
94 | if o.value == nil {
95 | return ""
96 | }
97 | return fmt.Sprint(*o.value)
98 | }
99 |
100 | // GoString returns the Go representation of the optional value
101 | func (o Optional[T]) GoString() string {
102 | if o.value == nil {
103 | return "nil"
104 | }
105 | return fmt.Sprintf("%#v", *o.value)
106 | }
107 |
--------------------------------------------------------------------------------
/routes.gen.go:
--------------------------------------------------------------------------------
1 | // Code generated by go.elara.ws/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.
2 |
3 | package lemmy
4 |
5 | import "context"
6 |
7 | // Add an admin to your site.
8 | func (c *Client) AddAdmin(ctx context.Context, data AddAdmin) (*AddAdminResponse, error) {
9 | resData := &AddAdminResponse{}
10 | res, err := c.req(ctx, "POST", "/admin/add", data, resData)
11 | if err != nil {
12 | return nil, err
13 | }
14 | err = resError(res, resData.Error)
15 | if err != nil {
16 | return nil, err
17 | }
18 | return resData, nil
19 | }
20 |
21 | // Add a moderator to your community.
22 | func (c *Client) AddModToCommunity(ctx context.Context, data AddModToCommunity) (*AddModToCommunityResponse, error) {
23 | resData := &AddModToCommunityResponse{}
24 | res, err := c.req(ctx, "POST", "/community/mod", data, resData)
25 | if err != nil {
26 | return nil, err
27 | }
28 | err = resError(res, resData.Error)
29 | if err != nil {
30 | return nil, err
31 | }
32 | return resData, nil
33 | }
34 |
35 | // Approve a registration application
36 | func (c *Client) ApproveRegistrationApplication(ctx context.Context, data ApproveRegistrationApplication) (*RegistrationApplicationResponse, error) {
37 | resData := &RegistrationApplicationResponse{}
38 | res, err := c.req(ctx, "PUT", "/admin/registration_application/approve", data, resData)
39 | if err != nil {
40 | return nil, err
41 | }
42 | err = resError(res, resData.Error)
43 | if err != nil {
44 | return nil, err
45 | }
46 | return resData, nil
47 | }
48 |
49 | // Ban a user from a community.
50 | func (c *Client) BanFromCommunity(ctx context.Context, data BanFromCommunity) (*BanFromCommunityResponse, error) {
51 | resData := &BanFromCommunityResponse{}
52 | res, err := c.req(ctx, "POST", "/community/ban_user", data, resData)
53 | if err != nil {
54 | return nil, err
55 | }
56 | err = resError(res, resData.Error)
57 | if err != nil {
58 | return nil, err
59 | }
60 | return resData, nil
61 | }
62 |
63 | // Ban a person from your site.
64 | func (c *Client) BanPerson(ctx context.Context, data BanPerson) (*BanPersonResponse, error) {
65 | resData := &BanPersonResponse{}
66 | res, err := c.req(ctx, "POST", "/user/ban", data, resData)
67 | if err != nil {
68 | return nil, err
69 | }
70 | err = resError(res, resData.Error)
71 | if err != nil {
72 | return nil, err
73 | }
74 | return resData, nil
75 | }
76 |
77 | // Block a community.
78 | func (c *Client) BlockCommunity(ctx context.Context, data BlockCommunity) (*BlockCommunityResponse, error) {
79 | resData := &BlockCommunityResponse{}
80 | res, err := c.req(ctx, "POST", "/community/block", data, resData)
81 | if err != nil {
82 | return nil, err
83 | }
84 | err = resError(res, resData.Error)
85 | if err != nil {
86 | return nil, err
87 | }
88 | return resData, nil
89 | }
90 |
91 | // Block an instance.
92 | func (c *Client) BlockInstance(ctx context.Context, data BlockInstance) (*BlockInstanceResponse, error) {
93 | resData := &BlockInstanceResponse{}
94 | res, err := c.req(ctx, "POST", "/site/block", data, resData)
95 | if err != nil {
96 | return nil, err
97 | }
98 | err = resError(res, resData.Error)
99 | if err != nil {
100 | return nil, err
101 | }
102 | return resData, nil
103 | }
104 |
105 | // Block a person.
106 | func (c *Client) BlockPerson(ctx context.Context, data BlockPerson) (*BlockPersonResponse, error) {
107 | resData := &BlockPersonResponse{}
108 | res, err := c.req(ctx, "POST", "/user/block", data, resData)
109 | if err != nil {
110 | return nil, err
111 | }
112 | err = resError(res, resData.Error)
113 | if err != nil {
114 | return nil, err
115 | }
116 | return resData, nil
117 | }
118 |
119 | // Change your user password.
120 | func (c *Client) ChangePassword(ctx context.Context, data ChangePassword) (*LoginResponse, error) {
121 | resData := &LoginResponse{}
122 | res, err := c.req(ctx, "PUT", "/user/change_password", data, resData)
123 | if err != nil {
124 | return nil, err
125 | }
126 | err = resError(res, resData.Error)
127 | if err != nil {
128 | return nil, err
129 | }
130 | return resData, nil
131 | }
132 |
133 | // Create a comment.
134 | func (c *Client) CreateComment(ctx context.Context, data CreateComment) (*CommentResponse, error) {
135 | resData := &CommentResponse{}
136 | res, err := c.req(ctx, "POST", "/comment", data, resData)
137 | if err != nil {
138 | return nil, err
139 | }
140 | err = resError(res, resData.Error)
141 | if err != nil {
142 | return nil, err
143 | }
144 | return resData, nil
145 | }
146 |
147 | // Report a comment.
148 | func (c *Client) CreateCommentReport(ctx context.Context, data CreateCommentReport) (*CommentReportResponse, error) {
149 | resData := &CommentReportResponse{}
150 | res, err := c.req(ctx, "POST", "/comment/report", data, resData)
151 | if err != nil {
152 | return nil, err
153 | }
154 | err = resError(res, resData.Error)
155 | if err != nil {
156 | return nil, err
157 | }
158 | return resData, nil
159 | }
160 |
161 | // Create a new community.
162 | func (c *Client) CreateCommunity(ctx context.Context, data CreateCommunity) (*CommunityResponse, error) {
163 | resData := &CommunityResponse{}
164 | res, err := c.req(ctx, "POST", "/community", data, resData)
165 | if err != nil {
166 | return nil, err
167 | }
168 | err = resError(res, resData.Error)
169 | if err != nil {
170 | return nil, err
171 | }
172 | return resData, nil
173 | }
174 |
175 | // Create a new custom emoji
176 | func (c *Client) CreateCustomEmoji(ctx context.Context, data CreateCustomEmoji) (*CustomEmojiResponse, error) {
177 | resData := &CustomEmojiResponse{}
178 | res, err := c.req(ctx, "POST", "/custom_emoji", data, resData)
179 | if err != nil {
180 | return nil, err
181 | }
182 | err = resError(res, resData.Error)
183 | if err != nil {
184 | return nil, err
185 | }
186 | return resData, nil
187 | }
188 |
189 | // Create a post.
190 | func (c *Client) CreatePost(ctx context.Context, data CreatePost) (*PostResponse, error) {
191 | resData := &PostResponse{}
192 | res, err := c.req(ctx, "POST", "/post", data, resData)
193 | if err != nil {
194 | return nil, err
195 | }
196 | err = resError(res, resData.Error)
197 | if err != nil {
198 | return nil, err
199 | }
200 | return resData, nil
201 | }
202 |
203 | // Report a post.
204 | func (c *Client) CreatePostReport(ctx context.Context, data CreatePostReport) (*PostReportResponse, error) {
205 | resData := &PostReportResponse{}
206 | res, err := c.req(ctx, "POST", "/post/report", data, resData)
207 | if err != nil {
208 | return nil, err
209 | }
210 | err = resError(res, resData.Error)
211 | if err != nil {
212 | return nil, err
213 | }
214 | return resData, nil
215 | }
216 |
217 | // Create a private message.
218 | func (c *Client) CreatePrivateMessage(ctx context.Context, data CreatePrivateMessage) (*PrivateMessageResponse, error) {
219 | resData := &PrivateMessageResponse{}
220 | res, err := c.req(ctx, "POST", "/private_message", data, resData)
221 | if err != nil {
222 | return nil, err
223 | }
224 | err = resError(res, resData.Error)
225 | if err != nil {
226 | return nil, err
227 | }
228 | return resData, nil
229 | }
230 |
231 | // Create a report for a private message.
232 | func (c *Client) CreatePrivateMessageReport(ctx context.Context, data CreatePrivateMessageReport) (*PrivateMessageReportResponse, error) {
233 | resData := &PrivateMessageReportResponse{}
234 | res, err := c.req(ctx, "POST", "/private_message/report", data, resData)
235 | if err != nil {
236 | return nil, err
237 | }
238 | err = resError(res, resData.Error)
239 | if err != nil {
240 | return nil, err
241 | }
242 | return resData, nil
243 | }
244 |
245 | // Create your site.
246 | func (c *Client) CreateSite(ctx context.Context, data CreateSite) (*SiteResponse, error) {
247 | resData := &SiteResponse{}
248 | res, err := c.req(ctx, "POST", "/site", data, resData)
249 | if err != nil {
250 | return nil, err
251 | }
252 | err = resError(res, resData.Error)
253 | if err != nil {
254 | return nil, err
255 | }
256 | return resData, nil
257 | }
258 |
259 | // Delete your account.
260 | func (c *Client) DeleteAccount(ctx context.Context, data DeleteAccount) (*SuccessResponse, error) {
261 | resData := &SuccessResponse{}
262 | res, err := c.req(ctx, "POST", "/user/delete_account", data, resData)
263 | if err != nil {
264 | return nil, err
265 | }
266 | err = resError(res, resData.Error)
267 | if err != nil {
268 | return nil, err
269 | }
270 | return resData, nil
271 | }
272 |
273 | // Delete a comment.
274 | func (c *Client) DeleteComment(ctx context.Context, data DeleteComment) (*CommentResponse, error) {
275 | resData := &CommentResponse{}
276 | res, err := c.req(ctx, "POST", "/comment/delete", data, resData)
277 | if err != nil {
278 | return nil, err
279 | }
280 | err = resError(res, resData.Error)
281 | if err != nil {
282 | return nil, err
283 | }
284 | return resData, nil
285 | }
286 |
287 | // Delete a community.
288 | func (c *Client) DeleteCommunity(ctx context.Context, data DeleteCommunity) (*CommunityResponse, error) {
289 | resData := &CommunityResponse{}
290 | res, err := c.req(ctx, "POST", "/community/delete", data, resData)
291 | if err != nil {
292 | return nil, err
293 | }
294 | err = resError(res, resData.Error)
295 | if err != nil {
296 | return nil, err
297 | }
298 | return resData, nil
299 | }
300 |
301 | // Delete a custom emoji
302 | func (c *Client) DeleteCustomEmoji(ctx context.Context, data DeleteCustomEmoji) (*SuccessResponse, error) {
303 | resData := &SuccessResponse{}
304 | res, err := c.req(ctx, "POST", "/custom_emoji/delete", data, resData)
305 | if err != nil {
306 | return nil, err
307 | }
308 | err = resError(res, resData.Error)
309 | if err != nil {
310 | return nil, err
311 | }
312 | return resData, nil
313 | }
314 |
315 | // Delete a post.
316 | func (c *Client) DeletePost(ctx context.Context, data DeletePost) (*PostResponse, error) {
317 | resData := &PostResponse{}
318 | res, err := c.req(ctx, "POST", "/post/delete", data, resData)
319 | if err != nil {
320 | return nil, err
321 | }
322 | err = resError(res, resData.Error)
323 | if err != nil {
324 | return nil, err
325 | }
326 | return resData, nil
327 | }
328 |
329 | // Delete a private message.
330 | func (c *Client) DeletePrivateMessage(ctx context.Context, data DeletePrivateMessage) (*PrivateMessageResponse, error) {
331 | resData := &PrivateMessageResponse{}
332 | res, err := c.req(ctx, "POST", "/private_message/delete", data, resData)
333 | if err != nil {
334 | return nil, err
335 | }
336 | err = resError(res, resData.Error)
337 | if err != nil {
338 | return nil, err
339 | }
340 | return resData, nil
341 | }
342 |
343 | // Distinguishes a comment (speak as moderator)
344 | func (c *Client) DistinguishComment(ctx context.Context, data DistinguishComment) (*CommentResponse, error) {
345 | resData := &CommentResponse{}
346 | res, err := c.req(ctx, "POST", "/comment/distinguish", data, resData)
347 | if err != nil {
348 | return nil, err
349 | }
350 | err = resError(res, resData.Error)
351 | if err != nil {
352 | return nil, err
353 | }
354 | return resData, nil
355 | }
356 |
357 | // Edit a comment.
358 | func (c *Client) EditComment(ctx context.Context, data EditComment) (*CommentResponse, error) {
359 | resData := &CommentResponse{}
360 | res, err := c.req(ctx, "PUT", "/comment", data, resData)
361 | if err != nil {
362 | return nil, err
363 | }
364 | err = resError(res, resData.Error)
365 | if err != nil {
366 | return nil, err
367 | }
368 | return resData, nil
369 | }
370 |
371 | // Edit a community.
372 | func (c *Client) EditCommunity(ctx context.Context, data EditCommunity) (*CommunityResponse, error) {
373 | resData := &CommunityResponse{}
374 | res, err := c.req(ctx, "PUT", "/community", data, resData)
375 | if err != nil {
376 | return nil, err
377 | }
378 | err = resError(res, resData.Error)
379 | if err != nil {
380 | return nil, err
381 | }
382 | return resData, nil
383 | }
384 |
385 | // Edit an existing custom emoji
386 | func (c *Client) EditCustomEmoji(ctx context.Context, data EditCustomEmoji) (*CustomEmojiResponse, error) {
387 | resData := &CustomEmojiResponse{}
388 | res, err := c.req(ctx, "PUT", "/custom_emoji", data, resData)
389 | if err != nil {
390 | return nil, err
391 | }
392 | err = resError(res, resData.Error)
393 | if err != nil {
394 | return nil, err
395 | }
396 | return resData, nil
397 | }
398 |
399 | // Edit a post.
400 | func (c *Client) EditPost(ctx context.Context, data EditPost) (*PostResponse, error) {
401 | resData := &PostResponse{}
402 | res, err := c.req(ctx, "PUT", "/post", data, resData)
403 | if err != nil {
404 | return nil, err
405 | }
406 | err = resError(res, resData.Error)
407 | if err != nil {
408 | return nil, err
409 | }
410 | return resData, nil
411 | }
412 |
413 | // Edit a private message.
414 | func (c *Client) EditPrivateMessage(ctx context.Context, data EditPrivateMessage) (*PrivateMessageResponse, error) {
415 | resData := &PrivateMessageResponse{}
416 | res, err := c.req(ctx, "PUT", "/private_message", data, resData)
417 | if err != nil {
418 | return nil, err
419 | }
420 | err = resError(res, resData.Error)
421 | if err != nil {
422 | return nil, err
423 | }
424 | return resData, nil
425 | }
426 |
427 | // Edit your site.
428 | func (c *Client) EditSite(ctx context.Context, data EditSite) (*SiteResponse, error) {
429 | resData := &SiteResponse{}
430 | res, err := c.req(ctx, "PUT", "/site", data, resData)
431 | if err != nil {
432 | return nil, err
433 | }
434 | err = resError(res, resData.Error)
435 | if err != nil {
436 | return nil, err
437 | }
438 | return resData, nil
439 | }
440 |
441 | /*
442 | Export a backup of your user settings, including your saved content,
443 | followed communities, and blocks.
444 | */
445 | func (c *Client) ExportSettings(ctx context.Context) (map[string]any, error) {
446 | resData := map[string]any{}
447 | res, err := c.getReq(ctx, "GET", "/user/export_settings", nil, &resData)
448 | if err != nil {
449 | return nil, err
450 | }
451 | err = resError(res, NewOptionalNil[string]())
452 | if err != nil {
453 | return nil, err
454 | }
455 | return resData, nil
456 | }
457 |
458 | // A moderator can feature a community post ( IE stick it to the top of a community ).
459 | func (c *Client) FeaturePost(ctx context.Context, data FeaturePost) (*PostResponse, error) {
460 | resData := &PostResponse{}
461 | res, err := c.req(ctx, "POST", "/post/feature", data, resData)
462 | if err != nil {
463 | return nil, err
464 | }
465 | err = resError(res, resData.Error)
466 | if err != nil {
467 | return nil, err
468 | }
469 | return resData, nil
470 | }
471 |
472 | // Follow / subscribe to a community.
473 | func (c *Client) FollowCommunity(ctx context.Context, data FollowCommunity) (*CommunityResponse, error) {
474 | resData := &CommunityResponse{}
475 | res, err := c.req(ctx, "POST", "/community/follow", data, resData)
476 | if err != nil {
477 | return nil, err
478 | }
479 | err = resError(res, resData.Error)
480 | if err != nil {
481 | return nil, err
482 | }
483 | return resData, nil
484 | }
485 |
486 | // Get a list of banned users
487 | func (c *Client) BannedPersons(ctx context.Context) (*BannedPersonsResponse, error) {
488 | resData := &BannedPersonsResponse{}
489 | res, err := c.getReq(ctx, "GET", "/user/banned", nil, resData)
490 | if err != nil {
491 | return nil, err
492 | }
493 | err = resError(res, resData.Error)
494 | if err != nil {
495 | return nil, err
496 | }
497 | return resData, nil
498 | }
499 |
500 | // Fetch a Captcha.
501 | func (c *Client) Captcha(ctx context.Context) (*GetCaptchaResponse, error) {
502 | resData := &GetCaptchaResponse{}
503 | res, err := c.getReq(ctx, "GET", "/user/get_captcha", nil, resData)
504 | if err != nil {
505 | return nil, err
506 | }
507 | err = resError(res, resData.Error)
508 | if err != nil {
509 | return nil, err
510 | }
511 | return resData, nil
512 | }
513 |
514 | // Get / fetch comment.
515 | func (c *Client) Comment(ctx context.Context, data GetComment) (*CommentResponse, error) {
516 | resData := &CommentResponse{}
517 | res, err := c.getReq(ctx, "GET", "/comment", data, resData)
518 | if err != nil {
519 | return nil, err
520 | }
521 | err = resError(res, resData.Error)
522 | if err != nil {
523 | return nil, err
524 | }
525 | return resData, nil
526 | }
527 |
528 | // Get / fetch comments.
529 | func (c *Client) Comments(ctx context.Context, data GetComments) (*GetCommentsResponse, error) {
530 | resData := &GetCommentsResponse{}
531 | res, err := c.getReq(ctx, "GET", "/comment/list", data, resData)
532 | if err != nil {
533 | return nil, err
534 | }
535 | err = resError(res, resData.Error)
536 | if err != nil {
537 | return nil, err
538 | }
539 | return resData, nil
540 | }
541 |
542 | // Get / fetch a community.
543 | func (c *Client) Community(ctx context.Context, data GetCommunity) (*GetCommunityResponse, error) {
544 | resData := &GetCommunityResponse{}
545 | res, err := c.getReq(ctx, "GET", "/community", data, resData)
546 | if err != nil {
547 | return nil, err
548 | }
549 | err = resError(res, resData.Error)
550 | if err != nil {
551 | return nil, err
552 | }
553 | return resData, nil
554 | }
555 |
556 | // Fetch federated instances.
557 | func (c *Client) FederatedInstances(ctx context.Context) (*GetFederatedInstancesResponse, error) {
558 | resData := &GetFederatedInstancesResponse{}
559 | res, err := c.getReq(ctx, "GET", "/federated_instances", nil, resData)
560 | if err != nil {
561 | return nil, err
562 | }
563 | err = resError(res, resData.Error)
564 | if err != nil {
565 | return nil, err
566 | }
567 | return resData, nil
568 | }
569 |
570 | // Get the modlog.
571 | func (c *Client) Modlog(ctx context.Context, data GetModlog) (*GetModlogResponse, error) {
572 | resData := &GetModlogResponse{}
573 | res, err := c.getReq(ctx, "GET", "/modlog", data, resData)
574 | if err != nil {
575 | return nil, err
576 | }
577 | err = resError(res, resData.Error)
578 | if err != nil {
579 | return nil, err
580 | }
581 | return resData, nil
582 | }
583 |
584 | // Get the details for a person.
585 | func (c *Client) PersonDetails(ctx context.Context, data GetPersonDetails) (*GetPersonDetailsResponse, error) {
586 | resData := &GetPersonDetailsResponse{}
587 | res, err := c.getReq(ctx, "GET", "/user", data, resData)
588 | if err != nil {
589 | return nil, err
590 | }
591 | err = resError(res, resData.Error)
592 | if err != nil {
593 | return nil, err
594 | }
595 | return resData, nil
596 | }
597 |
598 | // Get mentions for your user.
599 | func (c *Client) PersonMentions(ctx context.Context, data GetPersonMentions) (*GetPersonMentionsResponse, error) {
600 | resData := &GetPersonMentionsResponse{}
601 | res, err := c.getReq(ctx, "GET", "/user/mention", data, resData)
602 | if err != nil {
603 | return nil, err
604 | }
605 | err = resError(res, resData.Error)
606 | if err != nil {
607 | return nil, err
608 | }
609 | return resData, nil
610 | }
611 |
612 | // Get / fetch a post.
613 | func (c *Client) Post(ctx context.Context, data GetPost) (*GetPostResponse, error) {
614 | resData := &GetPostResponse{}
615 | res, err := c.getReq(ctx, "GET", "/post", data, resData)
616 | if err != nil {
617 | return nil, err
618 | }
619 | err = resError(res, resData.Error)
620 | if err != nil {
621 | return nil, err
622 | }
623 | return resData, nil
624 | }
625 |
626 | // Get / fetch posts, with various filters.
627 | func (c *Client) Posts(ctx context.Context, data GetPosts) (*GetPostsResponse, error) {
628 | resData := &GetPostsResponse{}
629 | res, err := c.getReq(ctx, "GET", "/post/list", data, resData)
630 | if err != nil {
631 | return nil, err
632 | }
633 | err = resError(res, resData.Error)
634 | if err != nil {
635 | return nil, err
636 | }
637 | return resData, nil
638 | }
639 |
640 | // Get / fetch private messages.
641 | func (c *Client) PrivateMessages(ctx context.Context, data GetPrivateMessages) (*PrivateMessagesResponse, error) {
642 | resData := &PrivateMessagesResponse{}
643 | res, err := c.getReq(ctx, "GET", "/private_message/list", data, resData)
644 | if err != nil {
645 | return nil, err
646 | }
647 | err = resError(res, resData.Error)
648 | if err != nil {
649 | return nil, err
650 | }
651 | return resData, nil
652 | }
653 |
654 | // Get comment replies.
655 | func (c *Client) Replies(ctx context.Context, data GetReplies) (*GetRepliesResponse, error) {
656 | resData := &GetRepliesResponse{}
657 | res, err := c.getReq(ctx, "GET", "/user/replies", data, resData)
658 | if err != nil {
659 | return nil, err
660 | }
661 | err = resError(res, resData.Error)
662 | if err != nil {
663 | return nil, err
664 | }
665 | return resData, nil
666 | }
667 |
668 | // Get counts for your reports
669 | func (c *Client) ReportCount(ctx context.Context, data GetReportCount) (*GetReportCountResponse, error) {
670 | resData := &GetReportCountResponse{}
671 | res, err := c.getReq(ctx, "GET", "/user/report_count", data, resData)
672 | if err != nil {
673 | return nil, err
674 | }
675 | err = resError(res, resData.Error)
676 | if err != nil {
677 | return nil, err
678 | }
679 | return resData, nil
680 | }
681 |
682 | // Gets the site, and your user data.
683 | func (c *Client) Site(ctx context.Context) (*GetSiteResponse, error) {
684 | resData := &GetSiteResponse{}
685 | res, err := c.getReq(ctx, "GET", "/site", nil, resData)
686 | if err != nil {
687 | return nil, err
688 | }
689 | err = resError(res, resData.Error)
690 | if err != nil {
691 | return nil, err
692 | }
693 | return resData, nil
694 | }
695 |
696 | // Fetch metadata for any given site.
697 | func (c *Client) SiteMetadata(ctx context.Context, data GetSiteMetadata) (*GetSiteMetadataResponse, error) {
698 | resData := &GetSiteMetadataResponse{}
699 | res, err := c.getReq(ctx, "GET", "/post/site_metadata", data, resData)
700 | if err != nil {
701 | return nil, err
702 | }
703 | err = resError(res, resData.Error)
704 | if err != nil {
705 | return nil, err
706 | }
707 | return resData, nil
708 | }
709 |
710 | // Get your unread counts
711 | func (c *Client) UnreadCount(ctx context.Context) (*GetUnreadCountResponse, error) {
712 | resData := &GetUnreadCountResponse{}
713 | res, err := c.getReq(ctx, "GET", "/user/unread_count", nil, resData)
714 | if err != nil {
715 | return nil, err
716 | }
717 | err = resError(res, resData.Error)
718 | if err != nil {
719 | return nil, err
720 | }
721 | return resData, nil
722 | }
723 |
724 | // Get the unread registration applications count.
725 | func (c *Client) UnreadRegistrationApplicationCount(ctx context.Context) (*GetUnreadRegistrationApplicationCountResponse, error) {
726 | resData := &GetUnreadRegistrationApplicationCountResponse{}
727 | res, err := c.getReq(ctx, "GET", "/admin/registration_application/count", nil, resData)
728 | if err != nil {
729 | return nil, err
730 | }
731 | err = resError(res, resData.Error)
732 | if err != nil {
733 | return nil, err
734 | }
735 | return resData, nil
736 | }
737 |
738 | // Hide a community from public / "All" view. Admins only.
739 | func (c *Client) HideCommunity(ctx context.Context, data HideCommunity) (*SuccessResponse, error) {
740 | resData := &SuccessResponse{}
741 | res, err := c.req(ctx, "PUT", "/community/hide", data, resData)
742 | if err != nil {
743 | return nil, err
744 | }
745 | err = resError(res, resData.Error)
746 | if err != nil {
747 | return nil, err
748 | }
749 | return resData, nil
750 | }
751 |
752 | // Import a backup of your user settings.
753 | func (c *Client) ImportSettings(ctx context.Context) (*SuccessResponse, error) {
754 | resData := &SuccessResponse{}
755 | res, err := c.req(ctx, "POST", "/user/import_settings", nil, resData)
756 | if err != nil {
757 | return nil, err
758 | }
759 | err = resError(res, resData.Error)
760 | if err != nil {
761 | return nil, err
762 | }
763 | return resData, nil
764 | }
765 |
766 | // Leave the Site admins.
767 | func (c *Client) LeaveAdmin(ctx context.Context) (*GetSiteResponse, error) {
768 | resData := &GetSiteResponse{}
769 | res, err := c.req(ctx, "POST", "/user/leave_admin", nil, resData)
770 | if err != nil {
771 | return nil, err
772 | }
773 | err = resError(res, resData.Error)
774 | if err != nil {
775 | return nil, err
776 | }
777 | return resData, nil
778 | }
779 |
780 | // Like / vote on a comment.
781 | func (c *Client) LikeComment(ctx context.Context, data CreateCommentLike) (*CommentResponse, error) {
782 | resData := &CommentResponse{}
783 | res, err := c.req(ctx, "POST", "/comment/like", data, resData)
784 | if err != nil {
785 | return nil, err
786 | }
787 | err = resError(res, resData.Error)
788 | if err != nil {
789 | return nil, err
790 | }
791 | return resData, nil
792 | }
793 |
794 | // Like / vote on a post.
795 | func (c *Client) LikePost(ctx context.Context, data CreatePostLike) (*PostResponse, error) {
796 | resData := &PostResponse{}
797 | res, err := c.req(ctx, "POST", "/post/like", data, resData)
798 | if err != nil {
799 | return nil, err
800 | }
801 | err = resError(res, resData.Error)
802 | if err != nil {
803 | return nil, err
804 | }
805 | return resData, nil
806 | }
807 |
808 | // List comment reports.
809 | func (c *Client) CommentReports(ctx context.Context, data ListCommentReports) (*ListCommentReportsResponse, error) {
810 | resData := &ListCommentReportsResponse{}
811 | res, err := c.getReq(ctx, "GET", "/comment/report/list", data, resData)
812 | if err != nil {
813 | return nil, err
814 | }
815 | err = resError(res, resData.Error)
816 | if err != nil {
817 | return nil, err
818 | }
819 | return resData, nil
820 | }
821 |
822 | // List communities, with various filters.
823 | func (c *Client) Communities(ctx context.Context, data ListCommunities) (*ListCommunitiesResponse, error) {
824 | resData := &ListCommunitiesResponse{}
825 | res, err := c.getReq(ctx, "GET", "/community/list", data, resData)
826 | if err != nil {
827 | return nil, err
828 | }
829 | err = resError(res, resData.Error)
830 | if err != nil {
831 | return nil, err
832 | }
833 | return resData, nil
834 | }
835 |
836 | // List login tokens for your user
837 | func (c *Client) Logins(ctx context.Context) error {
838 | resData := &emptyResponse{}
839 | res, err := c.getReq(ctx, "GET", "/user/list_logins", nil, resData)
840 | if err != nil {
841 | return err
842 | }
843 | err = resError(res, resData.Error)
844 | if err != nil {
845 | return err
846 | }
847 | return nil
848 | }
849 |
850 | // List post reports.
851 | func (c *Client) PostReports(ctx context.Context, data ListPostReports) (*ListPostReportsResponse, error) {
852 | resData := &ListPostReportsResponse{}
853 | res, err := c.getReq(ctx, "GET", "/post/report/list", data, resData)
854 | if err != nil {
855 | return nil, err
856 | }
857 | err = resError(res, resData.Error)
858 | if err != nil {
859 | return nil, err
860 | }
861 | return resData, nil
862 | }
863 |
864 | // List private message reports.
865 | func (c *Client) PrivateMessageReports(ctx context.Context, data ListPrivateMessageReports) (*ListPrivateMessageReportsResponse, error) {
866 | resData := &ListPrivateMessageReportsResponse{}
867 | res, err := c.getReq(ctx, "GET", "/private_message/report/list", data, resData)
868 | if err != nil {
869 | return nil, err
870 | }
871 | err = resError(res, resData.Error)
872 | if err != nil {
873 | return nil, err
874 | }
875 | return resData, nil
876 | }
877 |
878 | // List the registration applications.
879 | func (c *Client) RegistrationApplications(ctx context.Context, data ListRegistrationApplications) (*ListRegistrationApplicationsResponse, error) {
880 | resData := &ListRegistrationApplicationsResponse{}
881 | res, err := c.getReq(ctx, "GET", "/admin/registration_application/list", data, resData)
882 | if err != nil {
883 | return nil, err
884 | }
885 | err = resError(res, resData.Error)
886 | if err != nil {
887 | return nil, err
888 | }
889 | return resData, nil
890 | }
891 |
892 | // A moderator can lock a post ( IE disable new comments ).
893 | func (c *Client) LockPost(ctx context.Context, data LockPost) (*PostResponse, error) {
894 | resData := &PostResponse{}
895 | res, err := c.req(ctx, "POST", "/post/lock", data, resData)
896 | if err != nil {
897 | return nil, err
898 | }
899 | err = resError(res, resData.Error)
900 | if err != nil {
901 | return nil, err
902 | }
903 | return resData, nil
904 | }
905 |
906 | // Log into lemmy.
907 | func (c *Client) Login(ctx context.Context, data Login) (*LoginResponse, error) {
908 | resData := &LoginResponse{}
909 | res, err := c.req(ctx, "POST", "/user/login", data, resData)
910 | if err != nil {
911 | return nil, err
912 | }
913 | err = resError(res, resData.Error)
914 | if err != nil {
915 | return nil, err
916 | }
917 | return resData, nil
918 | }
919 |
920 | // Mark all replies as read.
921 | func (c *Client) MarkAllAsRead(ctx context.Context) (*GetRepliesResponse, error) {
922 | resData := &GetRepliesResponse{}
923 | res, err := c.req(ctx, "POST", "/user/mark_all_as_read", nil, resData)
924 | if err != nil {
925 | return nil, err
926 | }
927 | err = resError(res, resData.Error)
928 | if err != nil {
929 | return nil, err
930 | }
931 | return resData, nil
932 | }
933 |
934 | // Mark a comment as read.
935 | func (c *Client) MarkCommentReplyAsRead(ctx context.Context, data MarkCommentReplyAsRead) (*CommentReplyResponse, error) {
936 | resData := &CommentReplyResponse{}
937 | res, err := c.req(ctx, "POST", "/comment/mark_as_read", data, resData)
938 | if err != nil {
939 | return nil, err
940 | }
941 | err = resError(res, resData.Error)
942 | if err != nil {
943 | return nil, err
944 | }
945 | return resData, nil
946 | }
947 |
948 | // Mark a person mention as read.
949 | func (c *Client) MarkPersonMentionAsRead(ctx context.Context, data MarkPersonMentionAsRead) (*PersonMentionResponse, error) {
950 | resData := &PersonMentionResponse{}
951 | res, err := c.req(ctx, "POST", "/user/mention/mark_as_read", data, resData)
952 | if err != nil {
953 | return nil, err
954 | }
955 | err = resError(res, resData.Error)
956 | if err != nil {
957 | return nil, err
958 | }
959 | return resData, nil
960 | }
961 |
962 | // Mark a post as read.
963 | func (c *Client) MarkPostAsRead(ctx context.Context, data MarkPostAsRead) (*SuccessResponse, error) {
964 | resData := &SuccessResponse{}
965 | res, err := c.req(ctx, "POST", "/post/mark_as_read", data, resData)
966 | if err != nil {
967 | return nil, err
968 | }
969 | err = resError(res, resData.Error)
970 | if err != nil {
971 | return nil, err
972 | }
973 | return resData, nil
974 | }
975 |
976 | // Mark a private message as read.
977 | func (c *Client) MarkPrivateMessageAsRead(ctx context.Context, data MarkPrivateMessageAsRead) (*PrivateMessageResponse, error) {
978 | resData := &PrivateMessageResponse{}
979 | res, err := c.req(ctx, "POST", "/private_message/mark_as_read", data, resData)
980 | if err != nil {
981 | return nil, err
982 | }
983 | err = resError(res, resData.Error)
984 | if err != nil {
985 | return nil, err
986 | }
987 | return resData, nil
988 | }
989 |
990 | // Change your password from an email / token based reset.
991 | func (c *Client) PasswordChangeAfterReset(ctx context.Context, data PasswordChangeAfterReset) (*SuccessResponse, error) {
992 | resData := &SuccessResponse{}
993 | res, err := c.req(ctx, "POST", "/user/password_change", data, resData)
994 | if err != nil {
995 | return nil, err
996 | }
997 | err = resError(res, resData.Error)
998 | if err != nil {
999 | return nil, err
1000 | }
1001 | return resData, nil
1002 | }
1003 |
1004 | // Reset your password.
1005 | func (c *Client) PasswordReset(ctx context.Context, data PasswordReset) (*SuccessResponse, error) {
1006 | resData := &SuccessResponse{}
1007 | res, err := c.req(ctx, "POST", "/user/password_reset", data, resData)
1008 | if err != nil {
1009 | return nil, err
1010 | }
1011 | err = resError(res, resData.Error)
1012 | if err != nil {
1013 | return nil, err
1014 | }
1015 | return resData, nil
1016 | }
1017 |
1018 | // Purge / Delete a comment from the database.
1019 | func (c *Client) PurgeComment(ctx context.Context, data PurgeComment) (*SuccessResponse, error) {
1020 | resData := &SuccessResponse{}
1021 | res, err := c.req(ctx, "POST", "/admin/purge/comment", data, resData)
1022 | if err != nil {
1023 | return nil, err
1024 | }
1025 | err = resError(res, resData.Error)
1026 | if err != nil {
1027 | return nil, err
1028 | }
1029 | return resData, nil
1030 | }
1031 |
1032 | // Purge / Delete a community from the database.
1033 | func (c *Client) PurgeCommunity(ctx context.Context, data PurgeCommunity) (*SuccessResponse, error) {
1034 | resData := &SuccessResponse{}
1035 | res, err := c.req(ctx, "POST", "/admin/purge/community", data, resData)
1036 | if err != nil {
1037 | return nil, err
1038 | }
1039 | err = resError(res, resData.Error)
1040 | if err != nil {
1041 | return nil, err
1042 | }
1043 | return resData, nil
1044 | }
1045 |
1046 | // Purge / Delete a person from the database.
1047 | func (c *Client) PurgePerson(ctx context.Context, data PurgePerson) (*SuccessResponse, error) {
1048 | resData := &SuccessResponse{}
1049 | res, err := c.req(ctx, "POST", "/admin/purge/person", data, resData)
1050 | if err != nil {
1051 | return nil, err
1052 | }
1053 | err = resError(res, resData.Error)
1054 | if err != nil {
1055 | return nil, err
1056 | }
1057 | return resData, nil
1058 | }
1059 |
1060 | // Purge / Delete a post from the database.
1061 | func (c *Client) PurgePost(ctx context.Context, data PurgePost) (*SuccessResponse, error) {
1062 | resData := &SuccessResponse{}
1063 | res, err := c.req(ctx, "POST", "/admin/purge/post", data, resData)
1064 | if err != nil {
1065 | return nil, err
1066 | }
1067 | err = resError(res, resData.Error)
1068 | if err != nil {
1069 | return nil, err
1070 | }
1071 | return resData, nil
1072 | }
1073 |
1074 | // Register a new user.
1075 | func (c *Client) Register(ctx context.Context, data Register) (*LoginResponse, error) {
1076 | resData := &LoginResponse{}
1077 | res, err := c.req(ctx, "POST", "/user/register", data, resData)
1078 | if err != nil {
1079 | return nil, err
1080 | }
1081 | err = resError(res, resData.Error)
1082 | if err != nil {
1083 | return nil, err
1084 | }
1085 | return resData, nil
1086 | }
1087 |
1088 | // A moderator remove for a comment.
1089 | func (c *Client) RemoveComment(ctx context.Context, data RemoveComment) (*CommentResponse, error) {
1090 | resData := &CommentResponse{}
1091 | res, err := c.req(ctx, "POST", "/comment/remove", data, resData)
1092 | if err != nil {
1093 | return nil, err
1094 | }
1095 | err = resError(res, resData.Error)
1096 | if err != nil {
1097 | return nil, err
1098 | }
1099 | return resData, nil
1100 | }
1101 |
1102 | // A moderator remove for a community.
1103 | func (c *Client) RemoveCommunity(ctx context.Context, data RemoveCommunity) (*CommunityResponse, error) {
1104 | resData := &CommunityResponse{}
1105 | res, err := c.req(ctx, "POST", "/community/remove", data, resData)
1106 | if err != nil {
1107 | return nil, err
1108 | }
1109 | err = resError(res, resData.Error)
1110 | if err != nil {
1111 | return nil, err
1112 | }
1113 | return resData, nil
1114 | }
1115 |
1116 | // A moderator remove for a post.
1117 | func (c *Client) RemovePost(ctx context.Context, data RemovePost) (*PostResponse, error) {
1118 | resData := &PostResponse{}
1119 | res, err := c.req(ctx, "POST", "/post/remove", data, resData)
1120 | if err != nil {
1121 | return nil, err
1122 | }
1123 | err = resError(res, resData.Error)
1124 | if err != nil {
1125 | return nil, err
1126 | }
1127 | return resData, nil
1128 | }
1129 |
1130 | // Resolve a comment report. Only a mod can do this.
1131 | func (c *Client) ResolveCommentReport(ctx context.Context, data ResolveCommentReport) (*CommentReportResponse, error) {
1132 | resData := &CommentReportResponse{}
1133 | res, err := c.req(ctx, "PUT", "/comment/report/resolve", data, resData)
1134 | if err != nil {
1135 | return nil, err
1136 | }
1137 | err = resError(res, resData.Error)
1138 | if err != nil {
1139 | return nil, err
1140 | }
1141 | return resData, nil
1142 | }
1143 |
1144 | // Fetch a non-local / federated object.
1145 | func (c *Client) ResolveObject(ctx context.Context, data ResolveObject) (*ResolveObjectResponse, error) {
1146 | resData := &ResolveObjectResponse{}
1147 | res, err := c.getReq(ctx, "GET", "/resolve_object", data, resData)
1148 | if err != nil {
1149 | return nil, err
1150 | }
1151 | err = resError(res, resData.Error)
1152 | if err != nil {
1153 | return nil, err
1154 | }
1155 | return resData, nil
1156 | }
1157 |
1158 | // Resolve a post report. Only a mod can do this.
1159 | func (c *Client) ResolvePostReport(ctx context.Context, data ResolvePostReport) (*PostReportResponse, error) {
1160 | resData := &PostReportResponse{}
1161 | res, err := c.req(ctx, "PUT", "/post/report/resolve", data, resData)
1162 | if err != nil {
1163 | return nil, err
1164 | }
1165 | err = resError(res, resData.Error)
1166 | if err != nil {
1167 | return nil, err
1168 | }
1169 | return resData, nil
1170 | }
1171 |
1172 | // Resolve a report for a private message.
1173 | func (c *Client) ResolvePrivateMessageReport(ctx context.Context, data ResolvePrivateMessageReport) (*PrivateMessageReportResponse, error) {
1174 | resData := &PrivateMessageReportResponse{}
1175 | res, err := c.req(ctx, "PUT", "/private_message/report/resolve", data, resData)
1176 | if err != nil {
1177 | return nil, err
1178 | }
1179 | err = resError(res, resData.Error)
1180 | if err != nil {
1181 | return nil, err
1182 | }
1183 | return resData, nil
1184 | }
1185 |
1186 | // Save a comment.
1187 | func (c *Client) SaveComment(ctx context.Context, data SaveComment) (*CommentResponse, error) {
1188 | resData := &CommentResponse{}
1189 | res, err := c.req(ctx, "PUT", "/comment/save", data, resData)
1190 | if err != nil {
1191 | return nil, err
1192 | }
1193 | err = resError(res, resData.Error)
1194 | if err != nil {
1195 | return nil, err
1196 | }
1197 | return resData, nil
1198 | }
1199 |
1200 | // Save a post.
1201 | func (c *Client) SavePost(ctx context.Context, data SavePost) (*PostResponse, error) {
1202 | resData := &PostResponse{}
1203 | res, err := c.req(ctx, "PUT", "/post/save", data, resData)
1204 | if err != nil {
1205 | return nil, err
1206 | }
1207 | err = resError(res, resData.Error)
1208 | if err != nil {
1209 | return nil, err
1210 | }
1211 | return resData, nil
1212 | }
1213 |
1214 | // Save your user settings.
1215 | func (c *Client) SaveUserSettings(ctx context.Context, data SaveUserSettings) (*SuccessResponse, error) {
1216 | resData := &SuccessResponse{}
1217 | res, err := c.req(ctx, "PUT", "/user/save_user_settings", data, resData)
1218 | if err != nil {
1219 | return nil, err
1220 | }
1221 | err = resError(res, resData.Error)
1222 | if err != nil {
1223 | return nil, err
1224 | }
1225 | return resData, nil
1226 | }
1227 |
1228 | // Search lemmy.
1229 | func (c *Client) Search(ctx context.Context, data Search) (*SearchResponse, error) {
1230 | resData := &SearchResponse{}
1231 | res, err := c.getReq(ctx, "GET", "/search", data, resData)
1232 | if err != nil {
1233 | return nil, err
1234 | }
1235 | err = resError(res, resData.Error)
1236 | if err != nil {
1237 | return nil, err
1238 | }
1239 | return resData, nil
1240 | }
1241 |
1242 | // Transfer your community to an existing moderator.
1243 | func (c *Client) TransferCommunity(ctx context.Context, data TransferCommunity) (*GetCommunityResponse, error) {
1244 | resData := &GetCommunityResponse{}
1245 | res, err := c.req(ctx, "POST", "/community/transfer", data, resData)
1246 | if err != nil {
1247 | return nil, err
1248 | }
1249 | err = resError(res, resData.Error)
1250 | if err != nil {
1251 | return nil, err
1252 | }
1253 | return resData, nil
1254 | }
1255 |
1256 | // Returns an error message if your auth token is invalid
1257 | func (c *Client) ValidateAuth(ctx context.Context) (*SuccessResponse, error) {
1258 | resData := &SuccessResponse{}
1259 | res, err := c.getReq(ctx, "GET", "/user/validate_auth", nil, resData)
1260 | if err != nil {
1261 | return nil, err
1262 | }
1263 | err = resError(res, resData.Error)
1264 | if err != nil {
1265 | return nil, err
1266 | }
1267 | return resData, nil
1268 | }
1269 |
1270 | // Verify your email
1271 | func (c *Client) VerifyEmail(ctx context.Context, data VerifyEmail) (*SuccessResponse, error) {
1272 | resData := &SuccessResponse{}
1273 | res, err := c.req(ctx, "POST", "/user/verify_email", data, resData)
1274 | if err != nil {
1275 | return nil, err
1276 | }
1277 | err = resError(res, resData.Error)
1278 | if err != nil {
1279 | return nil, err
1280 | }
1281 | return resData, nil
1282 | }
1283 |
--------------------------------------------------------------------------------
/types.gen.go:
--------------------------------------------------------------------------------
1 | // Code generated by go.elara.ws/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
2 |
3 | package lemmy
4 |
5 | import "time"
6 |
7 | type BanPerson struct {
8 | Ban bool `json:"ban" url:"ban,omitempty"`
9 | Expires Optional[int64] `json:"expires" url:"expires,omitempty"`
10 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
11 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
12 | RemoveData Optional[bool] `json:"remove_data" url:"remove_data,omitempty"`
13 | }
14 | type BlockPersonResponse struct {
15 | Blocked bool `json:"blocked" url:"blocked,omitempty"`
16 | PersonView PersonView `json:"person_view" url:"person_view,omitempty"`
17 | Error Optional[string] `json:"error"`
18 | }
19 | type CommentReportView struct {
20 | Comment Comment `json:"comment" url:"comment,omitempty"`
21 | CommentCreator Person `json:"comment_creator" url:"comment_creator,omitempty"`
22 | CommentReport CommentReport `json:"comment_report" url:"comment_report,omitempty"`
23 | Community Community `json:"community" url:"community,omitempty"`
24 | Counts CommentAggregates `json:"counts" url:"counts,omitempty"`
25 | Creator Person `json:"creator" url:"creator,omitempty"`
26 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
27 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
28 | Post Post `json:"post" url:"post,omitempty"`
29 | Resolver Optional[Person] `json:"resolver" url:"resolver,omitempty"`
30 | }
31 | type BannedPersonsResponse struct {
32 | Banned []PersonView `json:"banned" url:"banned,omitempty"`
33 | Error Optional[string] `json:"error"`
34 | }
35 | type ModlogActionType string
36 |
37 | const (
38 | ModlogActionTypeAll ModlogActionType = "All"
39 | ModlogActionTypeModRemovePost ModlogActionType = "ModRemovePost"
40 | ModlogActionTypeModLockPost ModlogActionType = "ModLockPost"
41 | ModlogActionTypeModFeaturePost ModlogActionType = "ModFeaturePost"
42 | ModlogActionTypeModRemoveComment ModlogActionType = "ModRemoveComment"
43 | ModlogActionTypeModRemoveCommunity ModlogActionType = "ModRemoveCommunity"
44 | ModlogActionTypeModBanFromCommunity ModlogActionType = "ModBanFromCommunity"
45 | ModlogActionTypeModAddCommunity ModlogActionType = "ModAddCommunity"
46 | ModlogActionTypeModTransferCommunity ModlogActionType = "ModTransferCommunity"
47 | ModlogActionTypeModAdd ModlogActionType = "ModAdd"
48 | ModlogActionTypeModBan ModlogActionType = "ModBan"
49 | ModlogActionTypeModHideCommunity ModlogActionType = "ModHideCommunity"
50 | ModlogActionTypeAdminPurgePerson ModlogActionType = "AdminPurgePerson"
51 | ModlogActionTypeAdminPurgeCommunity ModlogActionType = "AdminPurgeCommunity"
52 | ModlogActionTypeAdminPurgePost ModlogActionType = "AdminPurgePost"
53 | ModlogActionTypeAdminPurgeComment ModlogActionType = "AdminPurgeComment"
54 | )
55 |
56 | type PersonView struct {
57 | Counts PersonAggregates `json:"counts" url:"counts,omitempty"`
58 | IsAdmin bool `json:"is_admin" url:"is_admin,omitempty"`
59 | Person Person `json:"person" url:"person,omitempty"`
60 | }
61 | type PostFeatureType string
62 |
63 | const (
64 | PostFeatureTypeLocal PostFeatureType = "Local"
65 | PostFeatureTypeCommunity PostFeatureType = "Community"
66 | )
67 |
68 | type ModBanView struct {
69 | BannedPerson Person `json:"banned_person" url:"banned_person,omitempty"`
70 | ModBan ModBan `json:"mod_ban" url:"mod_ban,omitempty"`
71 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
72 | }
73 | type ModRemoveComment struct {
74 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
75 | ID int64 `json:"id" url:"id,omitempty"`
76 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
77 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
78 | Removed bool `json:"removed" url:"removed,omitempty"`
79 | When time.Time `json:"when_" url:"when_,omitempty"`
80 | }
81 | type GetPersonDetailsResponse struct {
82 | Comments []CommentView `json:"comments" url:"comments,omitempty"`
83 | Moderates []CommunityModeratorView `json:"moderates" url:"moderates,omitempty"`
84 | PersonView PersonView `json:"person_view" url:"person_view,omitempty"`
85 | Posts []PostView `json:"posts" url:"posts,omitempty"`
86 | Error Optional[string] `json:"error"`
87 | }
88 | type Language struct {
89 | Code string `json:"code" url:"code,omitempty"`
90 | ID int64 `json:"id" url:"id,omitempty"`
91 | Name string `json:"name" url:"name,omitempty"`
92 | }
93 | type ResolvePostReport struct {
94 | ReportID int64 `json:"report_id" url:"report_id,omitempty"`
95 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
96 | }
97 | type LocalSite struct {
98 | ActorNameMaxLength int64 `json:"actor_name_max_length" url:"actor_name_max_length,omitempty"`
99 | ApplicationEmailAdmins bool `json:"application_email_admins" url:"application_email_admins,omitempty"`
100 | ApplicationQuestion Optional[string] `json:"application_question" url:"application_question,omitempty"`
101 | CaptchaDifficulty string `json:"captcha_difficulty" url:"captcha_difficulty,omitempty"`
102 | CaptchaEnabled bool `json:"captcha_enabled" url:"captcha_enabled,omitempty"`
103 | CommunityCreationAdminOnly bool `json:"community_creation_admin_only" url:"community_creation_admin_only,omitempty"`
104 | DefaultPostListingType ListingType `json:"default_post_listing_type" url:"default_post_listing_type,omitempty"`
105 | DefaultTheme string `json:"default_theme" url:"default_theme,omitempty"`
106 | EnableDownvotes bool `json:"enable_downvotes" url:"enable_downvotes,omitempty"`
107 | EnableNSFW bool `json:"enable_nsfw" url:"enable_nsfw,omitempty"`
108 | FederationEnabled bool `json:"federation_enabled" url:"federation_enabled,omitempty"`
109 | FederationSignedFetch bool `json:"federation_signed_fetch" url:"federation_signed_fetch,omitempty"`
110 | HideModlogModNames bool `json:"hide_modlog_mod_names" url:"hide_modlog_mod_names,omitempty"`
111 | ID int64 `json:"id" url:"id,omitempty"`
112 | LegalInformation Optional[string] `json:"legal_information" url:"legal_information,omitempty"`
113 | PrivateInstance bool `json:"private_instance" url:"private_instance,omitempty"`
114 | Published time.Time `json:"published" url:"published,omitempty"`
115 | RegistrationMode RegistrationMode `json:"registration_mode" url:"registration_mode,omitempty"`
116 | ReportsEmailAdmins bool `json:"reports_email_admins" url:"reports_email_admins,omitempty"`
117 | RequireEmailVerification bool `json:"require_email_verification" url:"require_email_verification,omitempty"`
118 | SiteID int64 `json:"site_id" url:"site_id,omitempty"`
119 | SiteSetup bool `json:"site_setup" url:"site_setup,omitempty"`
120 | SlurFilterRegex Optional[string] `json:"slur_filter_regex" url:"slur_filter_regex,omitempty"`
121 | Updated time.Time `json:"updated" url:"updated,omitempty"`
122 | }
123 | type DeleteCommunity struct {
124 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
125 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
126 | }
127 | type GetPostResponse struct {
128 | CommunityView CommunityView `json:"community_view" url:"community_view,omitempty"`
129 | CrossPosts []PostView `json:"cross_posts" url:"cross_posts,omitempty"`
130 | Moderators []CommunityModeratorView `json:"moderators" url:"moderators,omitempty"`
131 | PostView PostView `json:"post_view" url:"post_view,omitempty"`
132 | Error Optional[string] `json:"error"`
133 | }
134 | type PurgeComment struct {
135 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
136 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
137 | }
138 | type PurgeCommunity struct {
139 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
140 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
141 | }
142 | type DeletePrivateMessage struct {
143 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
144 | PrivateMessageID int64 `json:"private_message_id" url:"private_message_id,omitempty"`
145 | }
146 | type ModBanFromCommunityView struct {
147 | BannedPerson Person `json:"banned_person" url:"banned_person,omitempty"`
148 | Community Community `json:"community" url:"community,omitempty"`
149 | ModBanFromCommunity ModBanFromCommunity `json:"mod_ban_from_community" url:"mod_ban_from_community,omitempty"`
150 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
151 | }
152 | type MarkPostAsRead struct {
153 | PostID Optional[int64] `json:"post_id" url:"post_id,omitempty"`
154 | PostIDs Optional[[]int64] `json:"post_ids" url:"post_ids,omitempty"`
155 | Read bool `json:"read" url:"read,omitempty"`
156 | }
157 | type ListCommentReportsResponse struct {
158 | CommentReports []CommentReportView `json:"comment_reports" url:"comment_reports,omitempty"`
159 | Error Optional[string] `json:"error"`
160 | }
161 | type CommunityModeratorView struct {
162 | Community Community `json:"community" url:"community,omitempty"`
163 | Moderator Person `json:"moderator" url:"moderator,omitempty"`
164 | }
165 | type EditCustomEmoji struct {
166 | AltText string `json:"alt_text" url:"alt_text,omitempty"`
167 | Category string `json:"category" url:"category,omitempty"`
168 | ID int64 `json:"id" url:"id,omitempty"`
169 | ImageURL string `json:"image_url" url:"image_url,omitempty"`
170 | Keywords []string `json:"keywords" url:"keywords,omitempty"`
171 | }
172 | type GetReplies struct {
173 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
174 | Page Optional[int64] `json:"page" url:"page,omitempty"`
175 | Sort Optional[CommentSortType] `json:"sort" url:"sort,omitempty"`
176 | UnreadOnly Optional[bool] `json:"unread_only" url:"unread_only,omitempty"`
177 | }
178 | type CommunityBlockView struct {
179 | Community Community `json:"community" url:"community,omitempty"`
180 | Person Person `json:"person" url:"person,omitempty"`
181 | }
182 | type ListRegistrationApplicationsResponse struct {
183 | RegistrationApplications []RegistrationApplicationView `json:"registration_applications" url:"registration_applications,omitempty"`
184 | Error Optional[string] `json:"error"`
185 | }
186 | type SearchType string
187 |
188 | const (
189 | SearchTypeAll SearchType = "All"
190 | SearchTypeComments SearchType = "Comments"
191 | SearchTypePosts SearchType = "Posts"
192 | SearchTypeCommunities SearchType = "Communities"
193 | SearchTypeUsers SearchType = "Users"
194 | SearchTypeUrl SearchType = "Url"
195 | )
196 |
197 | type CommentAggregates struct {
198 | ChildCount int64 `json:"child_count" url:"child_count,omitempty"`
199 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
200 | Downvotes int64 `json:"downvotes" url:"downvotes,omitempty"`
201 | Published time.Time `json:"published" url:"published,omitempty"`
202 | Score int64 `json:"score" url:"score,omitempty"`
203 | Upvotes int64 `json:"upvotes" url:"upvotes,omitempty"`
204 | }
205 | type ListCommentReports struct {
206 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
207 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
208 | Page Optional[int64] `json:"page" url:"page,omitempty"`
209 | UnresolvedOnly Optional[bool] `json:"unresolved_only" url:"unresolved_only,omitempty"`
210 | }
211 | type AddAdmin struct {
212 | Added bool `json:"added" url:"added,omitempty"`
213 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
214 | }
215 | type AddModToCommunityResponse struct {
216 | Moderators []CommunityModeratorView `json:"moderators" url:"moderators,omitempty"`
217 | Error Optional[string] `json:"error"`
218 | }
219 | type RegistrationApplicationView struct {
220 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
221 | Creator Person `json:"creator" url:"creator,omitempty"`
222 | CreatorLocalUser LocalUser `json:"creator_local_user" url:"creator_local_user,omitempty"`
223 | RegistrationApplication RegistrationApplication `json:"registration_application" url:"registration_application,omitempty"`
224 | }
225 | type GetComment struct {
226 | ID int64 `json:"id" url:"id,omitempty"`
227 | }
228 | type GetPersonMentionsResponse struct {
229 | Mentions []PersonMentionView `json:"mentions" url:"mentions,omitempty"`
230 | Error Optional[string] `json:"error"`
231 | }
232 | type GetPosts struct {
233 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
234 | CommunityName Optional[string] `json:"community_name" url:"community_name,omitempty"`
235 | DislikedOnly Optional[bool] `json:"disliked_only" url:"disliked_only,omitempty"`
236 | LikedOnly Optional[bool] `json:"liked_only" url:"liked_only,omitempty"`
237 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
238 | Page Optional[int64] `json:"page" url:"page,omitempty"`
239 | PageCursor Optional[string] `json:"page_cursor" url:"page_cursor,omitempty"`
240 | SavedOnly Optional[bool] `json:"saved_only" url:"saved_only,omitempty"`
241 | Sort Optional[SortType] `json:"sort" url:"sort,omitempty"`
242 | Type Optional[ListingType] `json:"type_" url:"type_,omitempty"`
243 | }
244 | type PersonAggregates struct {
245 | CommentCount int64 `json:"comment_count" url:"comment_count,omitempty"`
246 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
247 | PostCount int64 `json:"post_count" url:"post_count,omitempty"`
248 | }
249 | type PrivateMessageReportResponse struct {
250 | PrivateMessageReportView PrivateMessageReportView `json:"private_message_report_view" url:"private_message_report_view,omitempty"`
251 | Error Optional[string] `json:"error"`
252 | }
253 | type ModTransferCommunityView struct {
254 | Community Community `json:"community" url:"community,omitempty"`
255 | ModTransferCommunity ModTransferCommunity `json:"mod_transfer_community" url:"mod_transfer_community,omitempty"`
256 | ModdedPerson Person `json:"modded_person" url:"modded_person,omitempty"`
257 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
258 | }
259 | type ListingType string
260 |
261 | const (
262 | ListingTypeAll ListingType = "All"
263 | ListingTypeLocal ListingType = "Local"
264 | ListingTypeSubscribed ListingType = "Subscribed"
265 | ListingTypeModeratorView ListingType = "ModeratorView"
266 | )
267 |
268 | type ModRemovePost struct {
269 | ID int64 `json:"id" url:"id,omitempty"`
270 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
271 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
272 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
273 | Removed bool `json:"removed" url:"removed,omitempty"`
274 | When time.Time `json:"when_" url:"when_,omitempty"`
275 | }
276 | type GetCommunity struct {
277 | ID Optional[int64] `json:"id" url:"id,omitempty"`
278 | Name Optional[string] `json:"name" url:"name,omitempty"`
279 | }
280 | type GetFederatedInstancesResponse struct {
281 | FederatedInstances Optional[FederatedInstances] `json:"federated_instances" url:"federated_instances,omitempty"`
282 | Error Optional[string] `json:"error"`
283 | }
284 | type GetModlogResponse struct {
285 | Added []ModAddView `json:"added" url:"added,omitempty"`
286 | AddedToCommunity []ModAddCommunityView `json:"added_to_community" url:"added_to_community,omitempty"`
287 | AdminPurgedComments []AdminPurgeCommentView `json:"admin_purged_comments" url:"admin_purged_comments,omitempty"`
288 | AdminPurgedCommunities []AdminPurgeCommunityView `json:"admin_purged_communities" url:"admin_purged_communities,omitempty"`
289 | AdminPurgedPersons []AdminPurgePersonView `json:"admin_purged_persons" url:"admin_purged_persons,omitempty"`
290 | AdminPurgedPosts []AdminPurgePostView `json:"admin_purged_posts" url:"admin_purged_posts,omitempty"`
291 | Banned []ModBanView `json:"banned" url:"banned,omitempty"`
292 | BannedFromCommunity []ModBanFromCommunityView `json:"banned_from_community" url:"banned_from_community,omitempty"`
293 | FeaturedPosts []ModFeaturePostView `json:"featured_posts" url:"featured_posts,omitempty"`
294 | HiddenCommunities []ModHideCommunityView `json:"hidden_communities" url:"hidden_communities,omitempty"`
295 | LockedPosts []ModLockPostView `json:"locked_posts" url:"locked_posts,omitempty"`
296 | RemovedComments []ModRemoveCommentView `json:"removed_comments" url:"removed_comments,omitempty"`
297 | RemovedCommunities []ModRemoveCommunityView `json:"removed_communities" url:"removed_communities,omitempty"`
298 | RemovedPosts []ModRemovePostView `json:"removed_posts" url:"removed_posts,omitempty"`
299 | TransferredToCommunity []ModTransferCommunityView `json:"transferred_to_community" url:"transferred_to_community,omitempty"`
300 | Error Optional[string] `json:"error"`
301 | }
302 | type ModFeaturePostView struct {
303 | Community Community `json:"community" url:"community,omitempty"`
304 | ModFeaturePost ModFeaturePost `json:"mod_feature_post" url:"mod_feature_post,omitempty"`
305 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
306 | Post Post `json:"post" url:"post,omitempty"`
307 | }
308 | type ModRemovePostView struct {
309 | Community Community `json:"community" url:"community,omitempty"`
310 | ModRemovePost ModRemovePost `json:"mod_remove_post" url:"mod_remove_post,omitempty"`
311 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
312 | Post Post `json:"post" url:"post,omitempty"`
313 | }
314 | type ListCommunities struct {
315 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
316 | Page Optional[int64] `json:"page" url:"page,omitempty"`
317 | ShowNSFW Optional[bool] `json:"show_nsfw" url:"show_nsfw,omitempty"`
318 | Sort Optional[SortType] `json:"sort" url:"sort,omitempty"`
319 | Type Optional[ListingType] `json:"type_" url:"type_,omitempty"`
320 | }
321 | type CommentSortType string
322 |
323 | const (
324 | CommentSortTypeHot CommentSortType = "Hot"
325 | CommentSortTypeTop CommentSortType = "Top"
326 | CommentSortTypeNew CommentSortType = "New"
327 | CommentSortTypeOld CommentSortType = "Old"
328 | CommentSortTypeControversial CommentSortType = "Controversial"
329 | )
330 |
331 | type SaveComment struct {
332 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
333 | Save bool `json:"save" url:"save,omitempty"`
334 | }
335 | type RegistrationApplication struct {
336 | AdminID Optional[int64] `json:"admin_id" url:"admin_id,omitempty"`
337 | Answer string `json:"answer" url:"answer,omitempty"`
338 | DenyReason Optional[string] `json:"deny_reason" url:"deny_reason,omitempty"`
339 | ID int64 `json:"id" url:"id,omitempty"`
340 | LocalUserID int64 `json:"local_user_id" url:"local_user_id,omitempty"`
341 | Published time.Time `json:"published" url:"published,omitempty"`
342 | }
343 | type ChangePassword struct {
344 | NewPassword string `json:"new_password" url:"new_password,omitempty"`
345 | NewPasswordVerify string `json:"new_password_verify" url:"new_password_verify,omitempty"`
346 | OldPassword string `json:"old_password" url:"old_password,omitempty"`
347 | }
348 | type PostView struct {
349 | Community Community `json:"community" url:"community,omitempty"`
350 | Counts PostAggregates `json:"counts" url:"counts,omitempty"`
351 | Creator Person `json:"creator" url:"creator,omitempty"`
352 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
353 | CreatorBlocked bool `json:"creator_blocked" url:"creator_blocked,omitempty"`
354 | CreatorIsAdmin bool `json:"creator_is_admin" url:"creator_is_admin,omitempty"`
355 | CreatorIsModerator bool `json:"creator_is_moderator" url:"creator_is_moderator,omitempty"`
356 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
357 | Post Post `json:"post" url:"post,omitempty"`
358 | Read bool `json:"read" url:"read,omitempty"`
359 | Saved bool `json:"saved" url:"saved,omitempty"`
360 | Subscribed SubscribedType `json:"subscribed" url:"subscribed,omitempty"`
361 | UnreadComments int64 `json:"unread_comments" url:"unread_comments,omitempty"`
362 | }
363 | type DeleteComment struct {
364 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
365 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
366 | }
367 | type AdminPurgePostView struct {
368 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
369 | AdminPurgePost AdminPurgePost `json:"admin_purge_post" url:"admin_purge_post,omitempty"`
370 | Community Community `json:"community" url:"community,omitempty"`
371 | }
372 | type Register struct {
373 | Answer Optional[string] `json:"answer" url:"answer,omitempty"`
374 | CaptchaAnswer Optional[string] `json:"captcha_answer" url:"captcha_answer,omitempty"`
375 | CaptchaUUID Optional[string] `json:"captcha_uuid" url:"captcha_uuid,omitempty"`
376 | Email Optional[string] `json:"email" url:"email,omitempty"`
377 | Honeypot Optional[string] `json:"honeypot" url:"honeypot,omitempty"`
378 | Password string `json:"password" url:"password,omitempty"`
379 | PasswordVerify string `json:"password_verify" url:"password_verify,omitempty"`
380 | ShowNSFW bool `json:"show_nsfw" url:"show_nsfw,omitempty"`
381 | Username string `json:"username" url:"username,omitempty"`
382 | }
383 | type Tagline struct {
384 | Content string `json:"content" url:"content,omitempty"`
385 | ID int64 `json:"id" url:"id,omitempty"`
386 | LocalSiteID int64 `json:"local_site_id" url:"local_site_id,omitempty"`
387 | Published time.Time `json:"published" url:"published,omitempty"`
388 | Updated time.Time `json:"updated" url:"updated,omitempty"`
389 | }
390 | type ListPostReports struct {
391 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
392 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
393 | Page Optional[int64] `json:"page" url:"page,omitempty"`
394 | UnresolvedOnly Optional[bool] `json:"unresolved_only" url:"unresolved_only,omitempty"`
395 | }
396 | type PasswordReset struct {
397 | Email string `json:"email" url:"email,omitempty"`
398 | }
399 | type ApproveRegistrationApplication struct {
400 | Approve bool `json:"approve" url:"approve,omitempty"`
401 | DenyReason Optional[string] `json:"deny_reason" url:"deny_reason,omitempty"`
402 | ID int64 `json:"id" url:"id,omitempty"`
403 | }
404 | type PostResponse struct {
405 | PostView PostView `json:"post_view" url:"post_view,omitempty"`
406 | Error Optional[string] `json:"error"`
407 | }
408 | type GetReportCountResponse struct {
409 | CommentReports int64 `json:"comment_reports" url:"comment_reports,omitempty"`
410 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
411 | PostReports int64 `json:"post_reports" url:"post_reports,omitempty"`
412 | PrivateMessageReports Optional[int64] `json:"private_message_reports" url:"private_message_reports,omitempty"`
413 | Error Optional[string] `json:"error"`
414 | }
415 | type Instance struct {
416 | Domain string `json:"domain" url:"domain,omitempty"`
417 | ID int64 `json:"id" url:"id,omitempty"`
418 | Published time.Time `json:"published" url:"published,omitempty"`
419 | Software Optional[string] `json:"software" url:"software,omitempty"`
420 | Updated time.Time `json:"updated" url:"updated,omitempty"`
421 | Version Optional[string] `json:"version" url:"version,omitempty"`
422 | }
423 | type CommunityAggregates struct {
424 | Comments int64 `json:"comments" url:"comments,omitempty"`
425 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
426 | Posts int64 `json:"posts" url:"posts,omitempty"`
427 | Published time.Time `json:"published" url:"published,omitempty"`
428 | Subscribers int64 `json:"subscribers" url:"subscribers,omitempty"`
429 | UsersActiveDay int64 `json:"users_active_day" url:"users_active_day,omitempty"`
430 | UsersActiveHalfYear int64 `json:"users_active_half_year" url:"users_active_half_year,omitempty"`
431 | UsersActiveMonth int64 `json:"users_active_month" url:"users_active_month,omitempty"`
432 | UsersActiveWeek int64 `json:"users_active_week" url:"users_active_week,omitempty"`
433 | }
434 | type PrivateMessageView struct {
435 | Creator Person `json:"creator" url:"creator,omitempty"`
436 | PrivateMessage PrivateMessage `json:"private_message" url:"private_message,omitempty"`
437 | Recipient Person `json:"recipient" url:"recipient,omitempty"`
438 | }
439 | type GetCommunityResponse struct {
440 | CommunityView CommunityView `json:"community_view" url:"community_view,omitempty"`
441 | DiscussionLanguages []int64 `json:"discussion_languages" url:"discussion_languages,omitempty"`
442 | Moderators []CommunityModeratorView `json:"moderators" url:"moderators,omitempty"`
443 | Site Optional[Site] `json:"site" url:"site,omitempty"`
444 | Error Optional[string] `json:"error"`
445 | }
446 | type ListPrivateMessageReports struct {
447 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
448 | Page Optional[int64] `json:"page" url:"page,omitempty"`
449 | UnresolvedOnly Optional[bool] `json:"unresolved_only" url:"unresolved_only,omitempty"`
450 | }
451 | type LockPost struct {
452 | Locked bool `json:"locked" url:"locked,omitempty"`
453 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
454 | }
455 | type TransferCommunity struct {
456 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
457 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
458 | }
459 | type CustomEmoji struct {
460 | AltText string `json:"alt_text" url:"alt_text,omitempty"`
461 | Category string `json:"category" url:"category,omitempty"`
462 | ID int64 `json:"id" url:"id,omitempty"`
463 | ImageURL string `json:"image_url" url:"image_url,omitempty"`
464 | LocalSiteID int64 `json:"local_site_id" url:"local_site_id,omitempty"`
465 | Published time.Time `json:"published" url:"published,omitempty"`
466 | Shortcode string `json:"shortcode" url:"shortcode,omitempty"`
467 | Updated time.Time `json:"updated" url:"updated,omitempty"`
468 | }
469 | type DeleteAccount struct {
470 | DeleteContent bool `json:"delete_content" url:"delete_content,omitempty"`
471 | Password string `json:"password" url:"password,omitempty"`
472 | }
473 | type DeleteCustomEmoji struct {
474 | ID int64 `json:"id" url:"id,omitempty"`
475 | }
476 | type ListPostReportsResponse struct {
477 | PostReports []PostReportView `json:"post_reports" url:"post_reports,omitempty"`
478 | Error Optional[string] `json:"error"`
479 | }
480 | type CreatePrivateMessageReport struct {
481 | PrivateMessageID int64 `json:"private_message_id" url:"private_message_id,omitempty"`
482 | Reason string `json:"reason" url:"reason,omitempty"`
483 | }
484 | type ModAddCommunityView struct {
485 | Community Community `json:"community" url:"community,omitempty"`
486 | ModAddCommunity ModAddCommunity `json:"mod_add_community" url:"mod_add_community,omitempty"`
487 | ModdedPerson Person `json:"modded_person" url:"modded_person,omitempty"`
488 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
489 | }
490 | type AdminPurgePost struct {
491 | AdminPersonID int64 `json:"admin_person_id" url:"admin_person_id,omitempty"`
492 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
493 | ID int64 `json:"id" url:"id,omitempty"`
494 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
495 | When time.Time `json:"when_" url:"when_,omitempty"`
496 | }
497 | type ModBan struct {
498 | Banned bool `json:"banned" url:"banned,omitempty"`
499 | Expires Optional[string] `json:"expires" url:"expires,omitempty"`
500 | ID int64 `json:"id" url:"id,omitempty"`
501 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
502 | OtherPersonID int64 `json:"other_person_id" url:"other_person_id,omitempty"`
503 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
504 | When time.Time `json:"when_" url:"when_,omitempty"`
505 | }
506 | type ResolvePrivateMessageReport struct {
507 | ReportID int64 `json:"report_id" url:"report_id,omitempty"`
508 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
509 | }
510 | type SavePost struct {
511 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
512 | Save bool `json:"save" url:"save,omitempty"`
513 | }
514 | type ModRemoveCommunityView struct {
515 | Community Community `json:"community" url:"community,omitempty"`
516 | ModRemoveCommunity ModRemoveCommunity `json:"mod_remove_community" url:"mod_remove_community,omitempty"`
517 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
518 | }
519 | type CommentReply struct {
520 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
521 | ID int64 `json:"id" url:"id,omitempty"`
522 | Published time.Time `json:"published" url:"published,omitempty"`
523 | Read bool `json:"read" url:"read,omitempty"`
524 | RecipientID int64 `json:"recipient_id" url:"recipient_id,omitempty"`
525 | }
526 | type SaveUserSettings struct {
527 | AutoExpand Optional[bool] `json:"auto_expand" url:"auto_expand,omitempty"`
528 | Avatar Optional[string] `json:"avatar" url:"avatar,omitempty"`
529 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
530 | Bio Optional[string] `json:"bio" url:"bio,omitempty"`
531 | BlurNSFW Optional[bool] `json:"blur_nsfw" url:"blur_nsfw,omitempty"`
532 | BotAccount Optional[bool] `json:"bot_account" url:"bot_account,omitempty"`
533 | CollapseBotComments Optional[bool] `json:"collapse_bot_comments" url:"collapse_bot_comments,omitempty"`
534 | DefaultListingType Optional[ListingType] `json:"default_listing_type" url:"default_listing_type,omitempty"`
535 | DefaultSortType Optional[SortType] `json:"default_sort_type" url:"default_sort_type,omitempty"`
536 | DiscussionLanguages Optional[[]int64] `json:"discussion_languages" url:"discussion_languages,omitempty"`
537 | DisplayName Optional[string] `json:"display_name" url:"display_name,omitempty"`
538 | Email Optional[string] `json:"email" url:"email,omitempty"`
539 | EnableAnimatedImages Optional[bool] `json:"enable_animated_images" url:"enable_animated_images,omitempty"`
540 | EnableKeyboardNavigation Optional[bool] `json:"enable_keyboard_navigation" url:"enable_keyboard_navigation,omitempty"`
541 | InfiniteScrollEnabled Optional[bool] `json:"infinite_scroll_enabled" url:"infinite_scroll_enabled,omitempty"`
542 | InterfaceLanguage Optional[string] `json:"interface_language" url:"interface_language,omitempty"`
543 | MatrixUserID Optional[string] `json:"matrix_user_id" url:"matrix_user_id,omitempty"`
544 | OpenLinksInNewTab Optional[bool] `json:"open_links_in_new_tab" url:"open_links_in_new_tab,omitempty"`
545 | PostListingMode Optional[PostListingMode] `json:"post_listing_mode" url:"post_listing_mode,omitempty"`
546 | SendNotificationsToEmail Optional[bool] `json:"send_notifications_to_email" url:"send_notifications_to_email,omitempty"`
547 | ShowAvatars Optional[bool] `json:"show_avatars" url:"show_avatars,omitempty"`
548 | ShowBotAccounts Optional[bool] `json:"show_bot_accounts" url:"show_bot_accounts,omitempty"`
549 | ShowNSFW Optional[bool] `json:"show_nsfw" url:"show_nsfw,omitempty"`
550 | ShowReadPosts Optional[bool] `json:"show_read_posts" url:"show_read_posts,omitempty"`
551 | ShowScores Optional[bool] `json:"show_scores" url:"show_scores,omitempty"`
552 | Theme Optional[string] `json:"theme" url:"theme,omitempty"`
553 | }
554 | type AddAdminResponse struct {
555 | Admins []PersonView `json:"admins" url:"admins,omitempty"`
556 | Error Optional[string] `json:"error"`
557 | }
558 | type CommentReport struct {
559 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
560 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
561 | ID int64 `json:"id" url:"id,omitempty"`
562 | OriginalCommentText string `json:"original_comment_text" url:"original_comment_text,omitempty"`
563 | Published time.Time `json:"published" url:"published,omitempty"`
564 | Reason string `json:"reason" url:"reason,omitempty"`
565 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
566 | ResolverID Optional[int64] `json:"resolver_id" url:"resolver_id,omitempty"`
567 | Updated time.Time `json:"updated" url:"updated,omitempty"`
568 | }
569 | type RemoveCommunity struct {
570 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
571 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
572 | Removed bool `json:"removed" url:"removed,omitempty"`
573 | }
574 | type FeaturePost struct {
575 | FeatureType PostFeatureType `json:"feature_type" url:"feature_type,omitempty"`
576 | Featured bool `json:"featured" url:"featured,omitempty"`
577 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
578 | }
579 | type ReadableFederationState struct {
580 | FailCount int64 `json:"fail_count" url:"fail_count,omitempty"`
581 | InstanceID int64 `json:"instance_id" url:"instance_id,omitempty"`
582 | LastRetry Optional[string] `json:"last_retry" url:"last_retry,omitempty"`
583 | LastSuccessfulID Optional[int64] `json:"last_successful_id" url:"last_successful_id,omitempty"`
584 | LastSuccessfulPublishedTime Optional[string] `json:"last_successful_published_time" url:"last_successful_published_time,omitempty"`
585 | NextRetry Optional[string] `json:"next_retry" url:"next_retry,omitempty"`
586 | }
587 | type AdminPurgePersonView struct {
588 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
589 | AdminPurgePerson AdminPurgePerson `json:"admin_purge_person" url:"admin_purge_person,omitempty"`
590 | }
591 | type MarkCommentReplyAsRead struct {
592 | CommentReplyID int64 `json:"comment_reply_id" url:"comment_reply_id,omitempty"`
593 | Read bool `json:"read" url:"read,omitempty"`
594 | }
595 | type EditPost struct {
596 | Body Optional[string] `json:"body" url:"body,omitempty"`
597 | LanguageID Optional[int64] `json:"language_id" url:"language_id,omitempty"`
598 | Name Optional[string] `json:"name" url:"name,omitempty"`
599 | NSFW Optional[bool] `json:"nsfw" url:"nsfw,omitempty"`
600 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
601 | URL Optional[string] `json:"url" url:"url,omitempty"`
602 | }
603 | type EditPrivateMessage struct {
604 | Content string `json:"content" url:"content,omitempty"`
605 | PrivateMessageID int64 `json:"private_message_id" url:"private_message_id,omitempty"`
606 | }
607 | type RegistrationApplicationResponse struct {
608 | RegistrationApplication RegistrationApplicationView `json:"registration_application" url:"registration_application,omitempty"`
609 | Error Optional[string] `json:"error"`
610 | }
611 | type PersonMentionView struct {
612 | Comment Comment `json:"comment" url:"comment,omitempty"`
613 | Community Community `json:"community" url:"community,omitempty"`
614 | Counts CommentAggregates `json:"counts" url:"counts,omitempty"`
615 | Creator Person `json:"creator" url:"creator,omitempty"`
616 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
617 | CreatorBlocked bool `json:"creator_blocked" url:"creator_blocked,omitempty"`
618 | CreatorIsAdmin bool `json:"creator_is_admin" url:"creator_is_admin,omitempty"`
619 | CreatorIsModerator bool `json:"creator_is_moderator" url:"creator_is_moderator,omitempty"`
620 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
621 | PersonMention PersonMention `json:"person_mention" url:"person_mention,omitempty"`
622 | Post Post `json:"post" url:"post,omitempty"`
623 | Recipient Person `json:"recipient" url:"recipient,omitempty"`
624 | Saved bool `json:"saved" url:"saved,omitempty"`
625 | Subscribed SubscribedType `json:"subscribed" url:"subscribed,omitempty"`
626 | }
627 | type PersonBlockView struct {
628 | Person Person `json:"person" url:"person,omitempty"`
629 | Target Person `json:"target" url:"target,omitempty"`
630 | }
631 | type SiteMetadata struct {
632 | Description Optional[string] `json:"description" url:"description,omitempty"`
633 | EmbedVideoURL Optional[string] `json:"embed_video_url" url:"embed_video_url,omitempty"`
634 | Image Optional[string] `json:"image" url:"image,omitempty"`
635 | Title Optional[string] `json:"title" url:"title,omitempty"`
636 | }
637 | type CreatePostLike struct {
638 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
639 | Score int64 `json:"score" url:"score,omitempty"`
640 | }
641 | type BlockCommunityResponse struct {
642 | Blocked bool `json:"blocked" url:"blocked,omitempty"`
643 | CommunityView CommunityView `json:"community_view" url:"community_view,omitempty"`
644 | Error Optional[string] `json:"error"`
645 | }
646 | type CreateCustomEmoji struct {
647 | AltText string `json:"alt_text" url:"alt_text,omitempty"`
648 | Category string `json:"category" url:"category,omitempty"`
649 | ImageURL string `json:"image_url" url:"image_url,omitempty"`
650 | Keywords []string `json:"keywords" url:"keywords,omitempty"`
651 | Shortcode string `json:"shortcode" url:"shortcode,omitempty"`
652 | }
653 | type ModHideCommunityView struct {
654 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
655 | Community Community `json:"community" url:"community,omitempty"`
656 | ModHideCommunity ModHideCommunity `json:"mod_hide_community" url:"mod_hide_community,omitempty"`
657 | }
658 | type MarkPersonMentionAsRead struct {
659 | PersonMentionID int64 `json:"person_mention_id" url:"person_mention_id,omitempty"`
660 | Read bool `json:"read" url:"read,omitempty"`
661 | }
662 | type LocalSiteRateLimit struct {
663 | Comment int64 `json:"comment" url:"comment,omitempty"`
664 | CommentPerSecond int64 `json:"comment_per_second" url:"comment_per_second,omitempty"`
665 | Image int64 `json:"image" url:"image,omitempty"`
666 | ImagePerSecond int64 `json:"image_per_second" url:"image_per_second,omitempty"`
667 | ImportUserSettings int64 `json:"import_user_settings" url:"import_user_settings,omitempty"`
668 | ImportUserSettingsPerSecond int64 `json:"import_user_settings_per_second" url:"import_user_settings_per_second,omitempty"`
669 | LocalSiteID int64 `json:"local_site_id" url:"local_site_id,omitempty"`
670 | Message int64 `json:"message" url:"message,omitempty"`
671 | MessagePerSecond int64 `json:"message_per_second" url:"message_per_second,omitempty"`
672 | Post int64 `json:"post" url:"post,omitempty"`
673 | PostPerSecond int64 `json:"post_per_second" url:"post_per_second,omitempty"`
674 | Published time.Time `json:"published" url:"published,omitempty"`
675 | Register int64 `json:"register" url:"register,omitempty"`
676 | RegisterPerSecond int64 `json:"register_per_second" url:"register_per_second,omitempty"`
677 | Search int64 `json:"search" url:"search,omitempty"`
678 | SearchPerSecond int64 `json:"search_per_second" url:"search_per_second,omitempty"`
679 | Updated time.Time `json:"updated" url:"updated,omitempty"`
680 | }
681 | type SuccessResponse struct {
682 | Success bool `json:"success" url:"success,omitempty"`
683 | Error Optional[string] `json:"error"`
684 | }
685 | type PrivateMessagesResponse struct {
686 | PrivateMessages []PrivateMessageView `json:"private_messages" url:"private_messages,omitempty"`
687 | Error Optional[string] `json:"error"`
688 | }
689 | type EditSite struct {
690 | ActorNameMaxLength Optional[int64] `json:"actor_name_max_length" url:"actor_name_max_length,omitempty"`
691 | AllowedInstances Optional[[]string] `json:"allowed_instances" url:"allowed_instances,omitempty"`
692 | ApplicationEmailAdmins Optional[bool] `json:"application_email_admins" url:"application_email_admins,omitempty"`
693 | ApplicationQuestion Optional[string] `json:"application_question" url:"application_question,omitempty"`
694 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
695 | BlockedInstances Optional[[]string] `json:"blocked_instances" url:"blocked_instances,omitempty"`
696 | CaptchaDifficulty Optional[string] `json:"captcha_difficulty" url:"captcha_difficulty,omitempty"`
697 | CaptchaEnabled Optional[bool] `json:"captcha_enabled" url:"captcha_enabled,omitempty"`
698 | CommunityCreationAdminOnly Optional[bool] `json:"community_creation_admin_only" url:"community_creation_admin_only,omitempty"`
699 | DefaultPostListingType Optional[ListingType] `json:"default_post_listing_type" url:"default_post_listing_type,omitempty"`
700 | DefaultTheme Optional[string] `json:"default_theme" url:"default_theme,omitempty"`
701 | Description Optional[string] `json:"description" url:"description,omitempty"`
702 | DiscussionLanguages Optional[[]int64] `json:"discussion_languages" url:"discussion_languages,omitempty"`
703 | EnableDownvotes Optional[bool] `json:"enable_downvotes" url:"enable_downvotes,omitempty"`
704 | EnableNSFW Optional[bool] `json:"enable_nsfw" url:"enable_nsfw,omitempty"`
705 | FederationDebug Optional[bool] `json:"federation_debug" url:"federation_debug,omitempty"`
706 | FederationEnabled Optional[bool] `json:"federation_enabled" url:"federation_enabled,omitempty"`
707 | HideModlogModNames Optional[bool] `json:"hide_modlog_mod_names" url:"hide_modlog_mod_names,omitempty"`
708 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
709 | LegalInformation Optional[string] `json:"legal_information" url:"legal_information,omitempty"`
710 | Name Optional[string] `json:"name" url:"name,omitempty"`
711 | PrivateInstance Optional[bool] `json:"private_instance" url:"private_instance,omitempty"`
712 | RateLimitComment Optional[int64] `json:"rate_limit_comment" url:"rate_limit_comment,omitempty"`
713 | RateLimitCommentPerSecond Optional[int64] `json:"rate_limit_comment_per_second" url:"rate_limit_comment_per_second,omitempty"`
714 | RateLimitImage Optional[int64] `json:"rate_limit_image" url:"rate_limit_image,omitempty"`
715 | RateLimitImagePerSecond Optional[int64] `json:"rate_limit_image_per_second" url:"rate_limit_image_per_second,omitempty"`
716 | RateLimitMessage Optional[int64] `json:"rate_limit_message" url:"rate_limit_message,omitempty"`
717 | RateLimitMessagePerSecond Optional[int64] `json:"rate_limit_message_per_second" url:"rate_limit_message_per_second,omitempty"`
718 | RateLimitPost Optional[int64] `json:"rate_limit_post" url:"rate_limit_post,omitempty"`
719 | RateLimitPostPerSecond Optional[int64] `json:"rate_limit_post_per_second" url:"rate_limit_post_per_second,omitempty"`
720 | RateLimitRegister Optional[int64] `json:"rate_limit_register" url:"rate_limit_register,omitempty"`
721 | RateLimitRegisterPerSecond Optional[int64] `json:"rate_limit_register_per_second" url:"rate_limit_register_per_second,omitempty"`
722 | RateLimitSearch Optional[int64] `json:"rate_limit_search" url:"rate_limit_search,omitempty"`
723 | RateLimitSearchPerSecond Optional[int64] `json:"rate_limit_search_per_second" url:"rate_limit_search_per_second,omitempty"`
724 | RegistrationMode Optional[RegistrationMode] `json:"registration_mode" url:"registration_mode,omitempty"`
725 | ReportsEmailAdmins Optional[bool] `json:"reports_email_admins" url:"reports_email_admins,omitempty"`
726 | RequireEmailVerification Optional[bool] `json:"require_email_verification" url:"require_email_verification,omitempty"`
727 | Sidebar Optional[string] `json:"sidebar" url:"sidebar,omitempty"`
728 | SlurFilterRegex Optional[string] `json:"slur_filter_regex" url:"slur_filter_regex,omitempty"`
729 | Taglines Optional[[]string] `json:"taglines" url:"taglines,omitempty"`
730 | }
731 | type ListRegistrationApplications struct {
732 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
733 | Page Optional[int64] `json:"page" url:"page,omitempty"`
734 | UnreadOnly Optional[bool] `json:"unread_only" url:"unread_only,omitempty"`
735 | }
736 | type Post struct {
737 | ApID string `json:"ap_id" url:"ap_id,omitempty"`
738 | Body Optional[string] `json:"body" url:"body,omitempty"`
739 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
740 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
741 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
742 | EmbedDescription Optional[string] `json:"embed_description" url:"embed_description,omitempty"`
743 | EmbedTitle Optional[string] `json:"embed_title" url:"embed_title,omitempty"`
744 | EmbedVideoURL Optional[string] `json:"embed_video_url" url:"embed_video_url,omitempty"`
745 | FeaturedCommunity bool `json:"featured_community" url:"featured_community,omitempty"`
746 | FeaturedLocal bool `json:"featured_local" url:"featured_local,omitempty"`
747 | ID int64 `json:"id" url:"id,omitempty"`
748 | LanguageID int64 `json:"language_id" url:"language_id,omitempty"`
749 | Local bool `json:"local" url:"local,omitempty"`
750 | Locked bool `json:"locked" url:"locked,omitempty"`
751 | Name string `json:"name" url:"name,omitempty"`
752 | NSFW bool `json:"nsfw" url:"nsfw,omitempty"`
753 | Published time.Time `json:"published" url:"published,omitempty"`
754 | Removed bool `json:"removed" url:"removed,omitempty"`
755 | ThumbnailURL Optional[string] `json:"thumbnail_url" url:"thumbnail_url,omitempty"`
756 | Updated time.Time `json:"updated" url:"updated,omitempty"`
757 | URL Optional[string] `json:"url" url:"url,omitempty"`
758 | }
759 | type CaptchaResponse struct {
760 | PNG string `json:"png" url:"png,omitempty"`
761 | UUID string `json:"uuid" url:"uuid,omitempty"`
762 | WAV string `json:"wav" url:"wav,omitempty"`
763 | Error Optional[string] `json:"error"`
764 | }
765 | type VerifyEmail struct {
766 | Token string `json:"token" url:"token,omitempty"`
767 | }
768 | type ModHideCommunity struct {
769 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
770 | Hidden bool `json:"hidden" url:"hidden,omitempty"`
771 | ID int64 `json:"id" url:"id,omitempty"`
772 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
773 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
774 | When time.Time `json:"when_" url:"when_,omitempty"`
775 | }
776 | type BanFromCommunityResponse struct {
777 | Banned bool `json:"banned" url:"banned,omitempty"`
778 | PersonView PersonView `json:"person_view" url:"person_view,omitempty"`
779 | Error Optional[string] `json:"error"`
780 | }
781 | type CommentView struct {
782 | Comment Comment `json:"comment" url:"comment,omitempty"`
783 | Community Community `json:"community" url:"community,omitempty"`
784 | Counts CommentAggregates `json:"counts" url:"counts,omitempty"`
785 | Creator Person `json:"creator" url:"creator,omitempty"`
786 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
787 | CreatorBlocked bool `json:"creator_blocked" url:"creator_blocked,omitempty"`
788 | CreatorIsAdmin bool `json:"creator_is_admin" url:"creator_is_admin,omitempty"`
789 | CreatorIsModerator bool `json:"creator_is_moderator" url:"creator_is_moderator,omitempty"`
790 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
791 | Post Post `json:"post" url:"post,omitempty"`
792 | Saved bool `json:"saved" url:"saved,omitempty"`
793 | Subscribed SubscribedType `json:"subscribed" url:"subscribed,omitempty"`
794 | }
795 | type AdminPurgeCommunityView struct {
796 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
797 | AdminPurgeCommunity AdminPurgeCommunity `json:"admin_purge_community" url:"admin_purge_community,omitempty"`
798 | }
799 | type PersonMentionResponse struct {
800 | PersonMentionView PersonMentionView `json:"person_mention_view" url:"person_mention_view,omitempty"`
801 | Error Optional[string] `json:"error"`
802 | }
803 | type BanFromCommunity struct {
804 | Ban bool `json:"ban" url:"ban,omitempty"`
805 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
806 | Expires Optional[int64] `json:"expires" url:"expires,omitempty"`
807 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
808 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
809 | RemoveData Optional[bool] `json:"remove_data" url:"remove_data,omitempty"`
810 | }
811 | type AdminPurgeCommentView struct {
812 | Admin Optional[Person] `json:"admin" url:"admin,omitempty"`
813 | AdminPurgeComment AdminPurgeComment `json:"admin_purge_comment" url:"admin_purge_comment,omitempty"`
814 | Post Post `json:"post" url:"post,omitempty"`
815 | }
816 | type LocalUser struct {
817 | AcceptedApplication bool `json:"accepted_application" url:"accepted_application,omitempty"`
818 | Admin bool `json:"admin" url:"admin,omitempty"`
819 | AutoExpand bool `json:"auto_expand" url:"auto_expand,omitempty"`
820 | BlurNSFW bool `json:"blur_nsfw" url:"blur_nsfw,omitempty"`
821 | CollapseBotComments bool `json:"collapse_bot_comments" url:"collapse_bot_comments,omitempty"`
822 | DefaultListingType ListingType `json:"default_listing_type" url:"default_listing_type,omitempty"`
823 | DefaultSortType SortType `json:"default_sort_type" url:"default_sort_type,omitempty"`
824 | Email Optional[string] `json:"email" url:"email,omitempty"`
825 | EmailVerified bool `json:"email_verified" url:"email_verified,omitempty"`
826 | EnableAnimatedImages bool `json:"enable_animated_images" url:"enable_animated_images,omitempty"`
827 | EnableKeyboardNavigation bool `json:"enable_keyboard_navigation" url:"enable_keyboard_navigation,omitempty"`
828 | ID int64 `json:"id" url:"id,omitempty"`
829 | InfiniteScrollEnabled bool `json:"infinite_scroll_enabled" url:"infinite_scroll_enabled,omitempty"`
830 | InterfaceLanguage string `json:"interface_language" url:"interface_language,omitempty"`
831 | OpenLinksInNewTab bool `json:"open_links_in_new_tab" url:"open_links_in_new_tab,omitempty"`
832 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
833 | PostListingMode PostListingMode `json:"post_listing_mode" url:"post_listing_mode,omitempty"`
834 | SendNotificationsToEmail bool `json:"send_notifications_to_email" url:"send_notifications_to_email,omitempty"`
835 | ShowAvatars bool `json:"show_avatars" url:"show_avatars,omitempty"`
836 | ShowBotAccounts bool `json:"show_bot_accounts" url:"show_bot_accounts,omitempty"`
837 | ShowNSFW bool `json:"show_nsfw" url:"show_nsfw,omitempty"`
838 | ShowReadPosts bool `json:"show_read_posts" url:"show_read_posts,omitempty"`
839 | ShowScores bool `json:"show_scores" url:"show_scores,omitempty"`
840 | Theme string `json:"theme" url:"theme,omitempty"`
841 | TOTP2FAEnabled bool `json:"totp_2fa_enabled" url:"totp_2fa_enabled,omitempty"`
842 | }
843 | type BlockCommunity struct {
844 | Block bool `json:"block" url:"block,omitempty"`
845 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
846 | }
847 | type Comment struct {
848 | ApID string `json:"ap_id" url:"ap_id,omitempty"`
849 | Content string `json:"content" url:"content,omitempty"`
850 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
851 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
852 | Distinguished bool `json:"distinguished" url:"distinguished,omitempty"`
853 | ID int64 `json:"id" url:"id,omitempty"`
854 | LanguageID int64 `json:"language_id" url:"language_id,omitempty"`
855 | Local bool `json:"local" url:"local,omitempty"`
856 | Path string `json:"path" url:"path,omitempty"`
857 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
858 | Published time.Time `json:"published" url:"published,omitempty"`
859 | Removed bool `json:"removed" url:"removed,omitempty"`
860 | Updated time.Time `json:"updated" url:"updated,omitempty"`
861 | }
862 | type CreatePostReport struct {
863 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
864 | Reason string `json:"reason" url:"reason,omitempty"`
865 | }
866 | type PrivateMessageReport struct {
867 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
868 | ID int64 `json:"id" url:"id,omitempty"`
869 | OriginalPMText string `json:"original_pm_text" url:"original_pm_text,omitempty"`
870 | PrivateMessageID int64 `json:"private_message_id" url:"private_message_id,omitempty"`
871 | Published time.Time `json:"published" url:"published,omitempty"`
872 | Reason string `json:"reason" url:"reason,omitempty"`
873 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
874 | ResolverID Optional[int64] `json:"resolver_id" url:"resolver_id,omitempty"`
875 | Updated time.Time `json:"updated" url:"updated,omitempty"`
876 | }
877 | type DistinguishComment struct {
878 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
879 | Distinguished bool `json:"distinguished" url:"distinguished,omitempty"`
880 | }
881 | type GetSiteResponse struct {
882 | Admins []PersonView `json:"admins" url:"admins,omitempty"`
883 | AllLanguages []Language `json:"all_languages" url:"all_languages,omitempty"`
884 | CustomEmojis []CustomEmojiView `json:"custom_emojis" url:"custom_emojis,omitempty"`
885 | DiscussionLanguages []int64 `json:"discussion_languages" url:"discussion_languages,omitempty"`
886 | MyUser Optional[MyUserInfo] `json:"my_user" url:"my_user,omitempty"`
887 | SiteView SiteView `json:"site_view" url:"site_view,omitempty"`
888 | Taglines []Tagline `json:"taglines" url:"taglines,omitempty"`
889 | Version string `json:"version" url:"version,omitempty"`
890 | Error Optional[string] `json:"error"`
891 | }
892 | type GetSiteMetadataResponse struct {
893 | Metadata SiteMetadata `json:"metadata" url:"metadata,omitempty"`
894 | Error Optional[string] `json:"error"`
895 | }
896 | type HideCommunity struct {
897 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
898 | Hidden bool `json:"hidden" url:"hidden,omitempty"`
899 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
900 | }
901 | type CreateCommentLike struct {
902 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
903 | Score int64 `json:"score" url:"score,omitempty"`
904 | }
905 | type Community struct {
906 | ActorID string `json:"actor_id" url:"actor_id,omitempty"`
907 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
908 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
909 | Description Optional[string] `json:"description" url:"description,omitempty"`
910 | Hidden bool `json:"hidden" url:"hidden,omitempty"`
911 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
912 | ID int64 `json:"id" url:"id,omitempty"`
913 | InstanceID int64 `json:"instance_id" url:"instance_id,omitempty"`
914 | Local bool `json:"local" url:"local,omitempty"`
915 | Name string `json:"name" url:"name,omitempty"`
916 | NSFW bool `json:"nsfw" url:"nsfw,omitempty"`
917 | PostingRestrictedToMods bool `json:"posting_restricted_to_mods" url:"posting_restricted_to_mods,omitempty"`
918 | Published time.Time `json:"published" url:"published,omitempty"`
919 | Removed bool `json:"removed" url:"removed,omitempty"`
920 | Title string `json:"title" url:"title,omitempty"`
921 | Updated time.Time `json:"updated" url:"updated,omitempty"`
922 | }
923 | type CommentReportResponse struct {
924 | CommentReportView CommentReportView `json:"comment_report_view" url:"comment_report_view,omitempty"`
925 | Error Optional[string] `json:"error"`
926 | }
927 | type ModRemoveCommunity struct {
928 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
929 | ID int64 `json:"id" url:"id,omitempty"`
930 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
931 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
932 | Removed bool `json:"removed" url:"removed,omitempty"`
933 | When time.Time `json:"when_" url:"when_,omitempty"`
934 | }
935 | type GetPrivateMessages struct {
936 | CreatorID Optional[int64] `json:"creator_id" url:"creator_id,omitempty"`
937 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
938 | Page Optional[int64] `json:"page" url:"page,omitempty"`
939 | UnreadOnly Optional[bool] `json:"unread_only" url:"unread_only,omitempty"`
940 | }
941 | type CommentReplyResponse struct {
942 | CommentReplyView CommentReplyView `json:"comment_reply_view" url:"comment_reply_view,omitempty"`
943 | Error Optional[string] `json:"error"`
944 | }
945 | type ResolveCommentReport struct {
946 | ReportID int64 `json:"report_id" url:"report_id,omitempty"`
947 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
948 | }
949 | type BlockPerson struct {
950 | Block bool `json:"block" url:"block,omitempty"`
951 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
952 | }
953 | type PostReportView struct {
954 | Community Community `json:"community" url:"community,omitempty"`
955 | Counts PostAggregates `json:"counts" url:"counts,omitempty"`
956 | Creator Person `json:"creator" url:"creator,omitempty"`
957 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
958 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
959 | Post Post `json:"post" url:"post,omitempty"`
960 | PostCreator Person `json:"post_creator" url:"post_creator,omitempty"`
961 | PostReport PostReport `json:"post_report" url:"post_report,omitempty"`
962 | Resolver Optional[Person] `json:"resolver" url:"resolver,omitempty"`
963 | }
964 | type CreateSite struct {
965 | ActorNameMaxLength Optional[int64] `json:"actor_name_max_length" url:"actor_name_max_length,omitempty"`
966 | AllowedInstances Optional[[]string] `json:"allowed_instances" url:"allowed_instances,omitempty"`
967 | ApplicationEmailAdmins Optional[bool] `json:"application_email_admins" url:"application_email_admins,omitempty"`
968 | ApplicationQuestion Optional[string] `json:"application_question" url:"application_question,omitempty"`
969 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
970 | BlockedInstances Optional[[]string] `json:"blocked_instances" url:"blocked_instances,omitempty"`
971 | CaptchaDifficulty Optional[string] `json:"captcha_difficulty" url:"captcha_difficulty,omitempty"`
972 | CaptchaEnabled Optional[bool] `json:"captcha_enabled" url:"captcha_enabled,omitempty"`
973 | CommunityCreationAdminOnly Optional[bool] `json:"community_creation_admin_only" url:"community_creation_admin_only,omitempty"`
974 | DefaultPostListingType Optional[ListingType] `json:"default_post_listing_type" url:"default_post_listing_type,omitempty"`
975 | DefaultTheme Optional[string] `json:"default_theme" url:"default_theme,omitempty"`
976 | Description Optional[string] `json:"description" url:"description,omitempty"`
977 | DiscussionLanguages Optional[[]int64] `json:"discussion_languages" url:"discussion_languages,omitempty"`
978 | EnableDownvotes Optional[bool] `json:"enable_downvotes" url:"enable_downvotes,omitempty"`
979 | EnableNSFW Optional[bool] `json:"enable_nsfw" url:"enable_nsfw,omitempty"`
980 | FederationDebug Optional[bool] `json:"federation_debug" url:"federation_debug,omitempty"`
981 | FederationEnabled Optional[bool] `json:"federation_enabled" url:"federation_enabled,omitempty"`
982 | HideModlogModNames Optional[bool] `json:"hide_modlog_mod_names" url:"hide_modlog_mod_names,omitempty"`
983 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
984 | LegalInformation Optional[string] `json:"legal_information" url:"legal_information,omitempty"`
985 | Name string `json:"name" url:"name,omitempty"`
986 | PrivateInstance Optional[bool] `json:"private_instance" url:"private_instance,omitempty"`
987 | RateLimitComment Optional[int64] `json:"rate_limit_comment" url:"rate_limit_comment,omitempty"`
988 | RateLimitCommentPerSecond Optional[int64] `json:"rate_limit_comment_per_second" url:"rate_limit_comment_per_second,omitempty"`
989 | RateLimitImage Optional[int64] `json:"rate_limit_image" url:"rate_limit_image,omitempty"`
990 | RateLimitImagePerSecond Optional[int64] `json:"rate_limit_image_per_second" url:"rate_limit_image_per_second,omitempty"`
991 | RateLimitMessage Optional[int64] `json:"rate_limit_message" url:"rate_limit_message,omitempty"`
992 | RateLimitMessagePerSecond Optional[int64] `json:"rate_limit_message_per_second" url:"rate_limit_message_per_second,omitempty"`
993 | RateLimitPost Optional[int64] `json:"rate_limit_post" url:"rate_limit_post,omitempty"`
994 | RateLimitPostPerSecond Optional[int64] `json:"rate_limit_post_per_second" url:"rate_limit_post_per_second,omitempty"`
995 | RateLimitRegister Optional[int64] `json:"rate_limit_register" url:"rate_limit_register,omitempty"`
996 | RateLimitRegisterPerSecond Optional[int64] `json:"rate_limit_register_per_second" url:"rate_limit_register_per_second,omitempty"`
997 | RateLimitSearch Optional[int64] `json:"rate_limit_search" url:"rate_limit_search,omitempty"`
998 | RateLimitSearchPerSecond Optional[int64] `json:"rate_limit_search_per_second" url:"rate_limit_search_per_second,omitempty"`
999 | RegistrationMode Optional[RegistrationMode] `json:"registration_mode" url:"registration_mode,omitempty"`
1000 | RequireEmailVerification Optional[bool] `json:"require_email_verification" url:"require_email_verification,omitempty"`
1001 | Sidebar Optional[string] `json:"sidebar" url:"sidebar,omitempty"`
1002 | SlurFilterRegex Optional[string] `json:"slur_filter_regex" url:"slur_filter_regex,omitempty"`
1003 | Taglines Optional[[]string] `json:"taglines" url:"taglines,omitempty"`
1004 | }
1005 | type ModRemoveCommentView struct {
1006 | Comment Comment `json:"comment" url:"comment,omitempty"`
1007 | Commenter Person `json:"commenter" url:"commenter,omitempty"`
1008 | Community Community `json:"community" url:"community,omitempty"`
1009 | ModRemoveComment ModRemoveComment `json:"mod_remove_comment" url:"mod_remove_comment,omitempty"`
1010 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
1011 | Post Post `json:"post" url:"post,omitempty"`
1012 | }
1013 | type ListPrivateMessageReportsResponse struct {
1014 | PrivateMessageReports []PrivateMessageReportView `json:"private_message_reports" url:"private_message_reports,omitempty"`
1015 | Error Optional[string] `json:"error"`
1016 | }
1017 | type AddModToCommunity struct {
1018 | Added bool `json:"added" url:"added,omitempty"`
1019 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1020 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
1021 | }
1022 | type BlockInstanceResponse struct {
1023 | Blocked bool `json:"blocked" url:"blocked,omitempty"`
1024 | Error Optional[string] `json:"error"`
1025 | }
1026 | type ModLockPost struct {
1027 | ID int64 `json:"id" url:"id,omitempty"`
1028 | Locked bool `json:"locked" url:"locked,omitempty"`
1029 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1030 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1031 | When time.Time `json:"when_" url:"when_,omitempty"`
1032 | }
1033 | type RegistrationMode string
1034 |
1035 | const (
1036 | RegistrationModeClosed RegistrationMode = "Closed"
1037 | RegistrationModeRequireApplication RegistrationMode = "RequireApplication"
1038 | RegistrationModeOpen RegistrationMode = "Open"
1039 | )
1040 |
1041 | type InstanceWithFederationState struct {
1042 | Domain string `json:"domain" url:"domain,omitempty"`
1043 | FederationState Optional[ReadableFederationState] `json:"federation_state" url:"federation_state,omitempty"`
1044 | ID int64 `json:"id" url:"id,omitempty"`
1045 | Published time.Time `json:"published" url:"published,omitempty"`
1046 | Software Optional[string] `json:"software" url:"software,omitempty"`
1047 | Updated time.Time `json:"updated" url:"updated,omitempty"`
1048 | Version Optional[string] `json:"version" url:"version,omitempty"`
1049 | }
1050 | type AdminPurgeCommunity struct {
1051 | AdminPersonID int64 `json:"admin_person_id" url:"admin_person_id,omitempty"`
1052 | ID int64 `json:"id" url:"id,omitempty"`
1053 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1054 | When time.Time `json:"when_" url:"when_,omitempty"`
1055 | }
1056 | type PurgePost struct {
1057 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1058 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1059 | }
1060 | type CommunityView struct {
1061 | Blocked bool `json:"blocked" url:"blocked,omitempty"`
1062 | Community Community `json:"community" url:"community,omitempty"`
1063 | Counts CommunityAggregates `json:"counts" url:"counts,omitempty"`
1064 | Subscribed SubscribedType `json:"subscribed" url:"subscribed,omitempty"`
1065 | }
1066 | type PostReport struct {
1067 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
1068 | ID int64 `json:"id" url:"id,omitempty"`
1069 | OriginalPostBody Optional[string] `json:"original_post_body" url:"original_post_body,omitempty"`
1070 | OriginalPostName string `json:"original_post_name" url:"original_post_name,omitempty"`
1071 | OriginalPostURL Optional[string] `json:"original_post_url" url:"original_post_url,omitempty"`
1072 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1073 | Published time.Time `json:"published" url:"published,omitempty"`
1074 | Reason string `json:"reason" url:"reason,omitempty"`
1075 | Resolved bool `json:"resolved" url:"resolved,omitempty"`
1076 | ResolverID Optional[int64] `json:"resolver_id" url:"resolver_id,omitempty"`
1077 | Updated time.Time `json:"updated" url:"updated,omitempty"`
1078 | }
1079 | type SiteView struct {
1080 | Counts SiteAggregates `json:"counts" url:"counts,omitempty"`
1081 | LocalSite LocalSite `json:"local_site" url:"local_site,omitempty"`
1082 | LocalSiteRateLimit LocalSiteRateLimit `json:"local_site_rate_limit" url:"local_site_rate_limit,omitempty"`
1083 | Site Site `json:"site" url:"site,omitempty"`
1084 | }
1085 | type ModFeaturePost struct {
1086 | Featured bool `json:"featured" url:"featured,omitempty"`
1087 | ID int64 `json:"id" url:"id,omitempty"`
1088 | IsFeaturedCommunity bool `json:"is_featured_community" url:"is_featured_community,omitempty"`
1089 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1090 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1091 | When time.Time `json:"when_" url:"when_,omitempty"`
1092 | }
1093 | type SubscribedType string
1094 |
1095 | const (
1096 | SubscribedTypeSubscribed SubscribedType = "Subscribed"
1097 | SubscribedTypeNotSubscribed SubscribedType = "NotSubscribed"
1098 | SubscribedTypePending SubscribedType = "Pending"
1099 | )
1100 |
1101 | type BlockInstance struct {
1102 | Block bool `json:"block" url:"block,omitempty"`
1103 | InstanceID int64 `json:"instance_id" url:"instance_id,omitempty"`
1104 | }
1105 | type CreateCommentReport struct {
1106 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
1107 | Reason string `json:"reason" url:"reason,omitempty"`
1108 | }
1109 | type SiteAggregates struct {
1110 | Comments int64 `json:"comments" url:"comments,omitempty"`
1111 | Communities int64 `json:"communities" url:"communities,omitempty"`
1112 | Posts int64 `json:"posts" url:"posts,omitempty"`
1113 | SiteID int64 `json:"site_id" url:"site_id,omitempty"`
1114 | Users int64 `json:"users" url:"users,omitempty"`
1115 | UsersActiveDay int64 `json:"users_active_day" url:"users_active_day,omitempty"`
1116 | UsersActiveHalfYear int64 `json:"users_active_half_year" url:"users_active_half_year,omitempty"`
1117 | UsersActiveMonth int64 `json:"users_active_month" url:"users_active_month,omitempty"`
1118 | UsersActiveWeek int64 `json:"users_active_week" url:"users_active_week,omitempty"`
1119 | }
1120 | type Site struct {
1121 | ActorID string `json:"actor_id" url:"actor_id,omitempty"`
1122 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
1123 | Description Optional[string] `json:"description" url:"description,omitempty"`
1124 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
1125 | ID int64 `json:"id" url:"id,omitempty"`
1126 | InboxURL string `json:"inbox_url" url:"inbox_url,omitempty"`
1127 | InstanceID int64 `json:"instance_id" url:"instance_id,omitempty"`
1128 | LastRefreshedAt string `json:"last_refreshed_at" url:"last_refreshed_at,omitempty"`
1129 | Name string `json:"name" url:"name,omitempty"`
1130 | PrivateKey Optional[string] `json:"private_key" url:"private_key,omitempty"`
1131 | PublicKey string `json:"public_key" url:"public_key,omitempty"`
1132 | Published time.Time `json:"published" url:"published,omitempty"`
1133 | Sidebar Optional[string] `json:"sidebar" url:"sidebar,omitempty"`
1134 | Updated time.Time `json:"updated" url:"updated,omitempty"`
1135 | }
1136 | type GetPostsResponse struct {
1137 | NextPage Optional[string] `json:"next_page" url:"next_page,omitempty"`
1138 | Posts []PostView `json:"posts" url:"posts,omitempty"`
1139 | Error Optional[string] `json:"error"`
1140 | }
1141 | type ListCommunitiesResponse struct {
1142 | Communities []CommunityView `json:"communities" url:"communities,omitempty"`
1143 | Error Optional[string] `json:"error"`
1144 | }
1145 | type GetRepliesResponse struct {
1146 | Replies []CommentReplyView `json:"replies" url:"replies,omitempty"`
1147 | Error Optional[string] `json:"error"`
1148 | }
1149 | type CommentReplyView struct {
1150 | Comment Comment `json:"comment" url:"comment,omitempty"`
1151 | CommentReply CommentReply `json:"comment_reply" url:"comment_reply,omitempty"`
1152 | Community Community `json:"community" url:"community,omitempty"`
1153 | Counts CommentAggregates `json:"counts" url:"counts,omitempty"`
1154 | Creator Person `json:"creator" url:"creator,omitempty"`
1155 | CreatorBannedFromCommunity bool `json:"creator_banned_from_community" url:"creator_banned_from_community,omitempty"`
1156 | CreatorBlocked bool `json:"creator_blocked" url:"creator_blocked,omitempty"`
1157 | CreatorIsAdmin bool `json:"creator_is_admin" url:"creator_is_admin,omitempty"`
1158 | CreatorIsModerator bool `json:"creator_is_moderator" url:"creator_is_moderator,omitempty"`
1159 | MyVote Optional[int64] `json:"my_vote" url:"my_vote,omitempty"`
1160 | Post Post `json:"post" url:"post,omitempty"`
1161 | Recipient Person `json:"recipient" url:"recipient,omitempty"`
1162 | Saved bool `json:"saved" url:"saved,omitempty"`
1163 | Subscribed SubscribedType `json:"subscribed" url:"subscribed,omitempty"`
1164 | }
1165 | type CreateCommunity struct {
1166 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
1167 | Description Optional[string] `json:"description" url:"description,omitempty"`
1168 | DiscussionLanguages Optional[[]int64] `json:"discussion_languages" url:"discussion_languages,omitempty"`
1169 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
1170 | Name string `json:"name" url:"name,omitempty"`
1171 | NSFW Optional[bool] `json:"nsfw" url:"nsfw,omitempty"`
1172 | PostingRestrictedToMods Optional[bool] `json:"posting_restricted_to_mods" url:"posting_restricted_to_mods,omitempty"`
1173 | Title string `json:"title" url:"title,omitempty"`
1174 | }
1175 | type CommunityResponse struct {
1176 | CommunityView CommunityView `json:"community_view" url:"community_view,omitempty"`
1177 | DiscussionLanguages []int64 `json:"discussion_languages" url:"discussion_languages,omitempty"`
1178 | Error Optional[string] `json:"error"`
1179 | }
1180 | type GetCommentsResponse struct {
1181 | Comments []CommentView `json:"comments" url:"comments,omitempty"`
1182 | Error Optional[string] `json:"error"`
1183 | }
1184 | type AdminPurgePerson struct {
1185 | AdminPersonID int64 `json:"admin_person_id" url:"admin_person_id,omitempty"`
1186 | ID int64 `json:"id" url:"id,omitempty"`
1187 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1188 | When time.Time `json:"when_" url:"when_,omitempty"`
1189 | }
1190 | type PersonMention struct {
1191 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
1192 | ID int64 `json:"id" url:"id,omitempty"`
1193 | Published time.Time `json:"published" url:"published,omitempty"`
1194 | Read bool `json:"read" url:"read,omitempty"`
1195 | RecipientID int64 `json:"recipient_id" url:"recipient_id,omitempty"`
1196 | }
1197 | type PrivateMessage struct {
1198 | ApID string `json:"ap_id" url:"ap_id,omitempty"`
1199 | Content string `json:"content" url:"content,omitempty"`
1200 | CreatorID int64 `json:"creator_id" url:"creator_id,omitempty"`
1201 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
1202 | ID int64 `json:"id" url:"id,omitempty"`
1203 | Local bool `json:"local" url:"local,omitempty"`
1204 | Published time.Time `json:"published" url:"published,omitempty"`
1205 | Read bool `json:"read" url:"read,omitempty"`
1206 | RecipientID int64 `json:"recipient_id" url:"recipient_id,omitempty"`
1207 | Updated time.Time `json:"updated" url:"updated,omitempty"`
1208 | }
1209 | type EditCommunity struct {
1210 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
1211 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1212 | Description Optional[string] `json:"description" url:"description,omitempty"`
1213 | DiscussionLanguages Optional[[]int64] `json:"discussion_languages" url:"discussion_languages,omitempty"`
1214 | Icon Optional[string] `json:"icon" url:"icon,omitempty"`
1215 | NSFW Optional[bool] `json:"nsfw" url:"nsfw,omitempty"`
1216 | PostingRestrictedToMods Optional[bool] `json:"posting_restricted_to_mods" url:"posting_restricted_to_mods,omitempty"`
1217 | Title Optional[string] `json:"title" url:"title,omitempty"`
1218 | }
1219 | type FederatedInstances struct {
1220 | Allowed []InstanceWithFederationState `json:"allowed" url:"allowed,omitempty"`
1221 | Blocked []InstanceWithFederationState `json:"blocked" url:"blocked,omitempty"`
1222 | Linked []InstanceWithFederationState `json:"linked" url:"linked,omitempty"`
1223 | }
1224 | type LocalUserView struct {
1225 | Counts PersonAggregates `json:"counts" url:"counts,omitempty"`
1226 | LocalUser LocalUser `json:"local_user" url:"local_user,omitempty"`
1227 | Person Person `json:"person" url:"person,omitempty"`
1228 | }
1229 | type RemoveComment struct {
1230 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
1231 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1232 | Removed bool `json:"removed" url:"removed,omitempty"`
1233 | }
1234 | type BanPersonResponse struct {
1235 | Banned bool `json:"banned" url:"banned,omitempty"`
1236 | PersonView PersonView `json:"person_view" url:"person_view,omitempty"`
1237 | Error Optional[string] `json:"error"`
1238 | }
1239 | type CreateComment struct {
1240 | Content string `json:"content" url:"content,omitempty"`
1241 | LanguageID Optional[int64] `json:"language_id" url:"language_id,omitempty"`
1242 | ParentID Optional[int64] `json:"parent_id" url:"parent_id,omitempty"`
1243 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1244 | }
1245 | type ModAdd struct {
1246 | ID int64 `json:"id" url:"id,omitempty"`
1247 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1248 | OtherPersonID int64 `json:"other_person_id" url:"other_person_id,omitempty"`
1249 | Removed bool `json:"removed" url:"removed,omitempty"`
1250 | When time.Time `json:"when_" url:"when_,omitempty"`
1251 | }
1252 | type CustomEmojiKeyword struct {
1253 | CustomEmojiID int64 `json:"custom_emoji_id" url:"custom_emoji_id,omitempty"`
1254 | Keyword string `json:"keyword" url:"keyword,omitempty"`
1255 | }
1256 | type DeletePost struct {
1257 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
1258 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1259 | }
1260 | type Person struct {
1261 | ActorID string `json:"actor_id" url:"actor_id,omitempty"`
1262 | Avatar Optional[string] `json:"avatar" url:"avatar,omitempty"`
1263 | BanExpires Optional[string] `json:"ban_expires" url:"ban_expires,omitempty"`
1264 | Banned bool `json:"banned" url:"banned,omitempty"`
1265 | Banner Optional[string] `json:"banner" url:"banner,omitempty"`
1266 | Bio Optional[string] `json:"bio" url:"bio,omitempty"`
1267 | BotAccount bool `json:"bot_account" url:"bot_account,omitempty"`
1268 | Deleted bool `json:"deleted" url:"deleted,omitempty"`
1269 | DisplayName Optional[string] `json:"display_name" url:"display_name,omitempty"`
1270 | ID int64 `json:"id" url:"id,omitempty"`
1271 | InstanceID int64 `json:"instance_id" url:"instance_id,omitempty"`
1272 | Local bool `json:"local" url:"local,omitempty"`
1273 | MatrixUserID Optional[string] `json:"matrix_user_id" url:"matrix_user_id,omitempty"`
1274 | Name string `json:"name" url:"name,omitempty"`
1275 | Published time.Time `json:"published" url:"published,omitempty"`
1276 | Updated time.Time `json:"updated" url:"updated,omitempty"`
1277 | }
1278 | type GetModlog struct {
1279 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
1280 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
1281 | ModPersonID Optional[int64] `json:"mod_person_id" url:"mod_person_id,omitempty"`
1282 | OtherPersonID Optional[int64] `json:"other_person_id" url:"other_person_id,omitempty"`
1283 | Page Optional[int64] `json:"page" url:"page,omitempty"`
1284 | Type Optional[ModlogActionType] `json:"type_" url:"type_,omitempty"`
1285 | }
1286 | type ModAddView struct {
1287 | ModAdd ModAdd `json:"mod_add" url:"mod_add,omitempty"`
1288 | ModdedPerson Person `json:"modded_person" url:"modded_person,omitempty"`
1289 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
1290 | }
1291 | type ModTransferCommunity struct {
1292 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1293 | ID int64 `json:"id" url:"id,omitempty"`
1294 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1295 | OtherPersonID int64 `json:"other_person_id" url:"other_person_id,omitempty"`
1296 | When time.Time `json:"when_" url:"when_,omitempty"`
1297 | }
1298 | type MarkPrivateMessageAsRead struct {
1299 | PrivateMessageID int64 `json:"private_message_id" url:"private_message_id,omitempty"`
1300 | Read bool `json:"read" url:"read,omitempty"`
1301 | }
1302 | type SiteResponse struct {
1303 | SiteView SiteView `json:"site_view" url:"site_view,omitempty"`
1304 | Taglines []Tagline `json:"taglines" url:"taglines,omitempty"`
1305 | Error Optional[string] `json:"error"`
1306 | }
1307 | type ModBanFromCommunity struct {
1308 | Banned bool `json:"banned" url:"banned,omitempty"`
1309 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1310 | Expires Optional[string] `json:"expires" url:"expires,omitempty"`
1311 | ID int64 `json:"id" url:"id,omitempty"`
1312 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1313 | OtherPersonID int64 `json:"other_person_id" url:"other_person_id,omitempty"`
1314 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1315 | When time.Time `json:"when_" url:"when_,omitempty"`
1316 | }
1317 | type PasswordChangeAfterReset struct {
1318 | Password string `json:"password" url:"password,omitempty"`
1319 | PasswordVerify string `json:"password_verify" url:"password_verify,omitempty"`
1320 | Token string `json:"token" url:"token,omitempty"`
1321 | }
1322 | type RemovePost struct {
1323 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1324 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1325 | Removed bool `json:"removed" url:"removed,omitempty"`
1326 | }
1327 | type CommentResponse struct {
1328 | CommentView CommentView `json:"comment_view" url:"comment_view,omitempty"`
1329 | RecipientIDs []int64 `json:"recipient_ids" url:"recipient_ids,omitempty"`
1330 | Error Optional[string] `json:"error"`
1331 | }
1332 | type PostAggregates struct {
1333 | Comments int64 `json:"comments" url:"comments,omitempty"`
1334 | Downvotes int64 `json:"downvotes" url:"downvotes,omitempty"`
1335 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1336 | Published time.Time `json:"published" url:"published,omitempty"`
1337 | Score int64 `json:"score" url:"score,omitempty"`
1338 | Upvotes int64 `json:"upvotes" url:"upvotes,omitempty"`
1339 | }
1340 | type PostReportResponse struct {
1341 | PostReportView PostReportView `json:"post_report_view" url:"post_report_view,omitempty"`
1342 | Error Optional[string] `json:"error"`
1343 | }
1344 | type GetCaptchaResponse struct {
1345 | Ok Optional[CaptchaResponse] `json:"ok" url:"ok,omitempty"`
1346 | Error Optional[string] `json:"error"`
1347 | }
1348 | type ResolveObjectResponse struct {
1349 | Comment Optional[CommentView] `json:"comment" url:"comment,omitempty"`
1350 | Community Optional[CommunityView] `json:"community" url:"community,omitempty"`
1351 | Person Optional[PersonView] `json:"person" url:"person,omitempty"`
1352 | Post Optional[PostView] `json:"post" url:"post,omitempty"`
1353 | Error Optional[string] `json:"error"`
1354 | }
1355 | type GetComments struct {
1356 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
1357 | CommunityName Optional[string] `json:"community_name" url:"community_name,omitempty"`
1358 | DislikedOnly Optional[bool] `json:"disliked_only" url:"disliked_only,omitempty"`
1359 | LikedOnly Optional[bool] `json:"liked_only" url:"liked_only,omitempty"`
1360 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
1361 | MaxDepth Optional[int64] `json:"max_depth" url:"max_depth,omitempty"`
1362 | Page Optional[int64] `json:"page" url:"page,omitempty"`
1363 | ParentID Optional[int64] `json:"parent_id" url:"parent_id,omitempty"`
1364 | PostID Optional[int64] `json:"post_id" url:"post_id,omitempty"`
1365 | SavedOnly Optional[bool] `json:"saved_only" url:"saved_only,omitempty"`
1366 | Sort Optional[CommentSortType] `json:"sort" url:"sort,omitempty"`
1367 | Type Optional[ListingType] `json:"type_" url:"type_,omitempty"`
1368 | }
1369 | type GetSiteMetadata struct {
1370 | URL string `json:"url" url:"url,omitempty"`
1371 | }
1372 | type FollowCommunity struct {
1373 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1374 | Follow bool `json:"follow" url:"follow,omitempty"`
1375 | }
1376 | type GetReportCount struct {
1377 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
1378 | }
1379 | type GetUnreadCountResponse struct {
1380 | Mentions int64 `json:"mentions" url:"mentions,omitempty"`
1381 | PrivateMessages int64 `json:"private_messages" url:"private_messages,omitempty"`
1382 | Replies int64 `json:"replies" url:"replies,omitempty"`
1383 | Error Optional[string] `json:"error"`
1384 | }
1385 | type CustomEmojiView struct {
1386 | CustomEmoji CustomEmoji `json:"custom_emoji" url:"custom_emoji,omitempty"`
1387 | Keywords []CustomEmojiKeyword `json:"keywords" url:"keywords,omitempty"`
1388 | }
1389 | type ModLockPostView struct {
1390 | Community Community `json:"community" url:"community,omitempty"`
1391 | ModLockPost ModLockPost `json:"mod_lock_post" url:"mod_lock_post,omitempty"`
1392 | Moderator Optional[Person] `json:"moderator" url:"moderator,omitempty"`
1393 | Post Post `json:"post" url:"post,omitempty"`
1394 | }
1395 | type CommunityFollowerView struct {
1396 | Community Community `json:"community" url:"community,omitempty"`
1397 | Follower Person `json:"follower" url:"follower,omitempty"`
1398 | }
1399 | type CreatePrivateMessage struct {
1400 | Content string `json:"content" url:"content,omitempty"`
1401 | RecipientID int64 `json:"recipient_id" url:"recipient_id,omitempty"`
1402 | }
1403 | type AdminPurgeComment struct {
1404 | AdminPersonID int64 `json:"admin_person_id" url:"admin_person_id,omitempty"`
1405 | ID int64 `json:"id" url:"id,omitempty"`
1406 | PostID int64 `json:"post_id" url:"post_id,omitempty"`
1407 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1408 | When time.Time `json:"when_" url:"when_,omitempty"`
1409 | }
1410 | type GetPersonDetails struct {
1411 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
1412 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
1413 | Page Optional[int64] `json:"page" url:"page,omitempty"`
1414 | PersonID Optional[int64] `json:"person_id" url:"person_id,omitempty"`
1415 | SavedOnly Optional[bool] `json:"saved_only" url:"saved_only,omitempty"`
1416 | Sort Optional[SortType] `json:"sort" url:"sort,omitempty"`
1417 | Username Optional[string] `json:"username" url:"username,omitempty"`
1418 | }
1419 | type GetPersonMentions struct {
1420 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
1421 | Page Optional[int64] `json:"page" url:"page,omitempty"`
1422 | Sort Optional[CommentSortType] `json:"sort" url:"sort,omitempty"`
1423 | UnreadOnly Optional[bool] `json:"unread_only" url:"unread_only,omitempty"`
1424 | }
1425 | type Login struct {
1426 | Password string `json:"password" url:"password,omitempty"`
1427 | TOTP2FAToken Optional[string] `json:"totp_2fa_token" url:"totp_2fa_token,omitempty"`
1428 | UsernameOrEmail string `json:"username_or_email" url:"username_or_email,omitempty"`
1429 | }
1430 | type ResolveObject struct {
1431 | Q string `json:"q" url:"q,omitempty"`
1432 | }
1433 | type CustomEmojiResponse struct {
1434 | CustomEmoji CustomEmojiView `json:"custom_emoji" url:"custom_emoji,omitempty"`
1435 | Error Optional[string] `json:"error"`
1436 | }
1437 | type PrivateMessageReportView struct {
1438 | Creator Person `json:"creator" url:"creator,omitempty"`
1439 | PrivateMessage PrivateMessage `json:"private_message" url:"private_message,omitempty"`
1440 | PrivateMessageCreator Person `json:"private_message_creator" url:"private_message_creator,omitempty"`
1441 | PrivateMessageReport PrivateMessageReport `json:"private_message_report" url:"private_message_report,omitempty"`
1442 | Resolver Optional[Person] `json:"resolver" url:"resolver,omitempty"`
1443 | }
1444 | type InstanceBlockView struct {
1445 | Instance Instance `json:"instance" url:"instance,omitempty"`
1446 | Person Person `json:"person" url:"person,omitempty"`
1447 | Site Optional[Site] `json:"site" url:"site,omitempty"`
1448 | }
1449 | type PurgePerson struct {
1450 | PersonID int64 `json:"person_id" url:"person_id,omitempty"`
1451 | Reason Optional[string] `json:"reason" url:"reason,omitempty"`
1452 | }
1453 | type SortType string
1454 |
1455 | const (
1456 | SortTypeActive SortType = "Active"
1457 | SortTypeHot SortType = "Hot"
1458 | SortTypeNew SortType = "New"
1459 | SortTypeOld SortType = "Old"
1460 | SortTypeTopDay SortType = "TopDay"
1461 | SortTypeTopWeek SortType = "TopWeek"
1462 | SortTypeTopMonth SortType = "TopMonth"
1463 | SortTypeTopYear SortType = "TopYear"
1464 | SortTypeTopAll SortType = "TopAll"
1465 | SortTypeMostComments SortType = "MostComments"
1466 | SortTypeNewComments SortType = "NewComments"
1467 | SortTypeTopHour SortType = "TopHour"
1468 | SortTypeTopSixHour SortType = "TopSixHour"
1469 | SortTypeTopTwelveHour SortType = "TopTwelveHour"
1470 | SortTypeTopThreeMonths SortType = "TopThreeMonths"
1471 | SortTypeTopSixMonths SortType = "TopSixMonths"
1472 | SortTypeTopNineMonths SortType = "TopNineMonths"
1473 | SortTypeControversial SortType = "Controversial"
1474 | SortTypeScaled SortType = "Scaled"
1475 | )
1476 |
1477 | type PostListingMode string
1478 |
1479 | const (
1480 | PostListingModeList PostListingMode = "List"
1481 | PostListingModeCard PostListingMode = "Card"
1482 | PostListingModeSmallCard PostListingMode = "SmallCard"
1483 | )
1484 |
1485 | type EditComment struct {
1486 | CommentID int64 `json:"comment_id" url:"comment_id,omitempty"`
1487 | Content Optional[string] `json:"content" url:"content,omitempty"`
1488 | LanguageID Optional[int64] `json:"language_id" url:"language_id,omitempty"`
1489 | }
1490 | type MyUserInfo struct {
1491 | CommunityBlocks []CommunityBlockView `json:"community_blocks" url:"community_blocks,omitempty"`
1492 | DiscussionLanguages []int64 `json:"discussion_languages" url:"discussion_languages,omitempty"`
1493 | Follows []CommunityFollowerView `json:"follows" url:"follows,omitempty"`
1494 | InstanceBlocks []InstanceBlockView `json:"instance_blocks" url:"instance_blocks,omitempty"`
1495 | LocalUserView LocalUserView `json:"local_user_view" url:"local_user_view,omitempty"`
1496 | Moderates []CommunityModeratorView `json:"moderates" url:"moderates,omitempty"`
1497 | PersonBlocks []PersonBlockView `json:"person_blocks" url:"person_blocks,omitempty"`
1498 | }
1499 | type Search struct {
1500 | CommunityID Optional[int64] `json:"community_id" url:"community_id,omitempty"`
1501 | CommunityName Optional[string] `json:"community_name" url:"community_name,omitempty"`
1502 | CreatorID Optional[int64] `json:"creator_id" url:"creator_id,omitempty"`
1503 | Limit Optional[int64] `json:"limit" url:"limit,omitempty"`
1504 | ListingType Optional[ListingType] `json:"listing_type" url:"listing_type,omitempty"`
1505 | Page Optional[int64] `json:"page" url:"page,omitempty"`
1506 | Q string `json:"q" url:"q,omitempty"`
1507 | Sort Optional[SortType] `json:"sort" url:"sort,omitempty"`
1508 | Type Optional[SearchType] `json:"type_" url:"type_,omitempty"`
1509 | }
1510 | type LoginResponse struct {
1511 | JWT Optional[string] `json:"jwt" url:"jwt,omitempty"`
1512 | RegistrationCreated bool `json:"registration_created" url:"registration_created,omitempty"`
1513 | VerifyEmailSent bool `json:"verify_email_sent" url:"verify_email_sent,omitempty"`
1514 | Error Optional[string] `json:"error"`
1515 | }
1516 | type CreatePost struct {
1517 | Body Optional[string] `json:"body" url:"body,omitempty"`
1518 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1519 | Honeypot Optional[string] `json:"honeypot" url:"honeypot,omitempty"`
1520 | LanguageID Optional[int64] `json:"language_id" url:"language_id,omitempty"`
1521 | Name string `json:"name" url:"name,omitempty"`
1522 | NSFW Optional[bool] `json:"nsfw" url:"nsfw,omitempty"`
1523 | URL Optional[string] `json:"url" url:"url,omitempty"`
1524 | }
1525 | type PrivateMessageResponse struct {
1526 | PrivateMessageView PrivateMessageView `json:"private_message_view" url:"private_message_view,omitempty"`
1527 | Error Optional[string] `json:"error"`
1528 | }
1529 | type ModAddCommunity struct {
1530 | CommunityID int64 `json:"community_id" url:"community_id,omitempty"`
1531 | ID int64 `json:"id" url:"id,omitempty"`
1532 | ModPersonID int64 `json:"mod_person_id" url:"mod_person_id,omitempty"`
1533 | OtherPersonID int64 `json:"other_person_id" url:"other_person_id,omitempty"`
1534 | Removed bool `json:"removed" url:"removed,omitempty"`
1535 | When time.Time `json:"when_" url:"when_,omitempty"`
1536 | }
1537 | type GetPost struct {
1538 | CommentID Optional[int64] `json:"comment_id" url:"comment_id,omitempty"`
1539 | ID Optional[int64] `json:"id" url:"id,omitempty"`
1540 | }
1541 | type GetUnreadRegistrationApplicationCountResponse struct {
1542 | RegistrationApplications int64 `json:"registration_applications" url:"registration_applications,omitempty"`
1543 | Error Optional[string] `json:"error"`
1544 | }
1545 | type SearchResponse struct {
1546 | Comments []CommentView `json:"comments" url:"comments,omitempty"`
1547 | Communities []CommunityView `json:"communities" url:"communities,omitempty"`
1548 | Posts []PostView `json:"posts" url:"posts,omitempty"`
1549 | Type SearchType `json:"type_" url:"type_,omitempty"`
1550 | Users []PersonView `json:"users" url:"users,omitempty"`
1551 | Error Optional[string] `json:"error"`
1552 | }
1553 |
--------------------------------------------------------------------------------