diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd18d89..c930a053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later * Allow trusted users to also create styles * Fix styles always returning 1 image +* Fix style reward not being taken from the requesting user # 4.44.1 diff --git a/horde/apis/v2/base.py b/horde/apis/v2/base.py index 701f1c2b..91e74c2f 100644 --- a/horde/apis/v2/base.py +++ b/horde/apis/v2/base.py @@ -123,6 +123,7 @@ def post(self): # It causes them to be a shared object from the parsers class self.params = {} self.warnings = set() + self.style_kudos = False if self.args.params: self.params = self.args.params self.models = [] @@ -349,7 +350,11 @@ def activate_waiting_prompt(self): _, _, ) = ensure_source_image_uploaded(eimg["image"], f"{self.wp.id}_exra_src_{iiter}", force_r2=True) - self.wp.activate(self.downgrade_wp_priority, extra_source_images=self.args.extra_source_images) + self.wp.activate( + self.downgrade_wp_priority, + extra_source_images=self.args.extra_source_images, + kudos_adjustment=2 if self.style_kudos is True else 0, + ) class SyncGenerate(GenerateTemplate): diff --git a/horde/apis/v2/kobold.py b/horde/apis/v2/kobold.py index 7f87dd96..8ad5b3d6 100644 --- a/horde/apis/v2/kobold.py +++ b/horde/apis/v2/kobold.py @@ -190,7 +190,6 @@ def apply_style(self): self.existing_style = database.get_style_by_uuid(self.args.style) if not self.existing_style: self.existing_style = database.get_style_by_name(self.args.style) - logger.debug(self.existing_style) if not self.existing_style: raise e.ThingNotFound("Style", self.args.style) if self.existing_style.style_type != "text": @@ -209,7 +208,9 @@ def apply_style(self): self.params["n"] = requested_n self.nsfw = self.existing_style.nsfw self.existing_style.use_count += 1 - self.existing_style.user.record_style(2, "text") + if self.existing_style.user != self.user: + self.existing_style.user.record_style(2, "text") + self.style_kudos = True db.session.commit() logger.debug(f"Style '{self.args.style}' applied.") diff --git a/horde/apis/v2/stable.py b/horde/apis/v2/stable.py index c0679c6f..80a2105c 100644 --- a/horde/apis/v2/stable.py +++ b/horde/apis/v2/stable.py @@ -357,6 +357,7 @@ def activate_waiting_prompt(self): source_image=self.source_image, source_mask=self.source_mask, extra_source_images=self.args.extra_source_images, + kudos_adjustment=2 if self.existing_style is not None else 0, ) def apply_style(self): @@ -372,8 +373,8 @@ def apply_style(self): if isinstance(self.existing_style, StyleCollection): colstyles = self.existing_style.styles random.shuffle(colstyles) - self.existing_style.use_count += 1 self.existing_style = colstyles[0] + self.existing_style.use_count += 1 self.models = self.existing_style.get_model_names() self.negprompt = "" if "###" in self.args.prompt: @@ -388,7 +389,10 @@ def apply_style(self): self.params["n"] = requested_n self.nsfw = self.existing_style.nsfw self.existing_style.use_count += 1 - self.existing_style.user.record_style(2, "image") + # We don't reward kudos to ourselves + if self.existing_style.user != self.user: + self.existing_style.user.record_style(2, "image") + self.style_kudos = True db.session.commit() logger.debug(f"Style '{self.args.style}' applied.")