Skip to content

Commit

Permalink
feat: rename subscriptions to interests
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Jun 11, 2024
1 parent b8ae332 commit 226bb21
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ func main() {
},
{
Text: "app",
Description: "Manage Subscriptions and Publishing in Application",
Description: "Manage Interests and Publishing in the Application",
},
{
Text: "pub",
Description: "Publish a basic Message",
},
{
Text: "sub",
Description: "Subscribe for Keywords",
Description: "Follow a new basic interest",
},
{
Text: "donate",
Expand Down
2 changes: 1 addition & 1 deletion service/chats/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package chats
import "errors"

var ErrAlreadyExists = errors.New("chat already exists")
var ErrNotFound = errors.New("chat or subscription not found")
var ErrNotFound = errors.New("chat or interest not found")
var ErrInternal = errors.New("internal failure")
4 changes: 2 additions & 2 deletions service/chats/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ func (h handler) handleFloodError(ctx context.Context, tgCtx telebot.Context, su
return tgCtx.Send(
"⚠ High message rate detected. "+
"Results streaming stopped to prevent a further flood. "+
"Typical cause: subscription's conditions are too vague. "+
"Typical cause: interest conditions are too vague. "+
"Review the <a href=\"https://awakari.com/sub-details.html?id="+subId+
"\">subscription</a> and make it more specific. "+
"\">interest</a> and make it more specific. "+
"Link it back to a chat later using the /start command of the bot.",
telebot.ModeHTML,
)
Expand Down
4 changes: 2 additions & 2 deletions service/messages/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func (f Format) convert(evt *pb.CloudEvent, subId, subDescr string, mode FormatM
//
switch mode {
case FormatModeHtml:
txt += "Subscription: <a href=\"https://awakari.com/sub-details.html?id=" + subId + "\">" + subDescr + "</a>\n\n"
txt += "Interest: <a href=\"https://awakari.com/sub-details.html?id=" + subId + "\">" + subDescr + "</a>\n\n"
default:
txt += "Subscription: " + subDescr + "\n\n"
txt += "Interest: " + subDescr + "\n\n"
}
//
var attrsTxt string
Expand Down
2 changes: 1 addition & 1 deletion service/messages/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Increase your daily publication limit or nominate own sources for the dedicated
If you did not publish messages, <a href="https://awakari.com/pub.html?own=true" rel="nofollow">check own publication sources</a...
Subscription: <a href="https://awakari.com/sub-details.html?id=sub1">sub1 description</a>
Interest: <a href="https://awakari.com/sub-details.html?id=sub1">sub1 description</a>
<span class="tg-spoiler">id: 82f39262-5eb4-4f7f-9142-7c489d670907
source: https://bbs.archlinux.org/extern.php?action=feed&fid=32&type=atom
Expand Down
8 changes: 4 additions & 4 deletions service/prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ type PricesHandler struct {
}

const fmtMsgPrices = `<b>Always Free</b>:
🎁 1 subscription that never expires.
🎁 Follow up to 1 interest forever.
🎁 Up to 20 message publications daily ¹.
🎁 Adding own publishing sources.
<b>Prices</b> (in %s):
<i>Payments are currently in the test mode. There are no real money transfer.</i>
Committed Usage:
- Subscriptions quota ²:
- Interests quota ²:
<pre> %.2f per item-day</pre>
- Message publications quota ³:
<pre> %.2f per item-day</pre>
On Demand:
- Extend a subscription time:
- Extend an interest following time:
<pre> %.2f per day</pre>
- Publish a message after the current limit is reached:
<pre> %.2f per message</pre>
(1) Includes the messages been published from added sources.
(2) Starting from 2nd subscription.
(2) Starting from 2nd interest.
(3) Starting from 11th message per day.`

func (ph PricesHandler) Prices(tgCtx telebot.Context) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion service/subscriptions/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (ch ConditionHandler) Update(tgCtx telebot.Context, args ...string) (err er
err = ch.ClientAwk.UpdateSubscription(groupIdCtx, userId, subId, sd)
}
if err == nil {
_ = tgCtx.Send("Subscription updated.")
_ = tgCtx.Send("Interest updated.")
}
return
}
Expand Down
14 changes: 7 additions & 7 deletions service/subscriptions/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const maxTextCondTermsLength = 256
const expiresDefaultDuration = time.Hour * 24 * usage.ExpiresDefaultDays // ~ month

const ReqSubCreate = "sub_create"
const msgSubCreate = "Creating a simple text subscription. " +
const msgSubCreate = "Following a simple text interest. " +
"Reply a name followed by keywords to the next message. Example:\n" +
"<pre>Wishlist1 tesla iphone</pre>"
const msgSubCreated = "If you want to read it in another chat, unlink it first using the <pre>/start</pre> command."

var errCreateSubNotEnoughArgs = errors.New("not enough arguments to create a text subscription")
var errInvalidCondition = errors.New("invalid subscription condition")
var errCreateSubNotEnoughArgs = errors.New("not enough arguments to create a text interest")
var errInvalidCondition = errors.New("invalid interest condition")
var errLimitReached = errors.New("limit reached")
var whiteSpaceRegex = regexp.MustCompile(`\p{Zs}+`)

Expand Down Expand Up @@ -77,12 +77,12 @@ func CreateBasicReplyHandlerFunc(
if err == nil {
err = start(tgCtx, clientAwk, svcReader, urlCallbackBase, subId, groupId)
} else {
err = fmt.Errorf("failed to create the subscription:\n%w", err)
err = fmt.Errorf("failed to register the interest:\n%w", err)
}
if err == nil {
err = tgCtx.Send(msgSubCreated, telebot.ModeHTML)
} else {
err = fmt.Errorf("failed to link the created subscription to this chat:\n%w", err)
err = fmt.Errorf("failed to follow the interest to this chat:\n%w", err)
}
return
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func decodeNumOp(src subscriptions.Operation) (dst condition.NumOp) {

func validateSubscriptionData(sd subscription.Data) (err error) {
if sd.Description == "" {
err = errors.New("invalid subscription:\nempty description")
err = errors.New("invalid interest:\nempty description")
}
if err == nil {
err = validateCondition(sd.Condition)
Expand All @@ -148,7 +148,7 @@ func validateCondition(cond condition.Condition) (err error) {
countChildren := len(children)
if tc.GetLogic() == condition.GroupLogicOr && countChildren > limitGroupOrCondChildrenCount {
err = fmt.Errorf(
"%w:\nchildren condition count for the group condition with \"Or\" logic is %d, limit is %d,\nconsider to use an additional subscription instead",
"%w:\nchildren condition count for the group condition with \"Or\" logic is %d, limit is %d,\nconsider to follow an additional interest instead",
errInvalidCondition,
countChildren,
limitGroupOrCondChildrenCount,
Expand Down
2 changes: 1 addition & 1 deletion service/subscriptions/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func DescriptionReplyHandlerFunc(clientAwk api.Client, groupId string) service.A
}
if err == nil {
// force reply removes the keyboard, hence don't forget to restore it
err = tgCtx.Send(fmt.Sprintf("Subscription description changed to \"%s\"", descr))
err = tgCtx.Send(fmt.Sprintf("Interest description changed to \"%s\"", descr))
}
return
}
Expand Down
10 changes: 5 additions & 5 deletions service/subscriptions/extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CmdExtend = "extend"
const ReqSubExtend = "sub_extend"
const daysMin = 10
const daysMax = 365
const msgFmtRunOnceFailed = "failed to extend the subscription, id: %s, user id: %s, cause: %s, retrying in: %s"
const msgFmtRunOnceFailed = "failed to extend the interest following, id: %s, user id: %s, cause: %s, retrying in: %s"

type ExtendHandler struct {
CfgPayment config.PaymentConfig
Expand Down Expand Up @@ -90,8 +90,8 @@ func (eh ExtendHandler) HandleExtensionReply(tgCtx telebot.Context, args ...stri
price := int(float64(countDays) * eh.CfgPayment.Price.Subscription.Extension * eh.CfgPayment.Currency.SubFactor)
invoice := telebot.Invoice{
Start: uuid.NewString(),
Title: "Subscription Extension",
Description: fmt.Sprintf("Subscription %s: extend by %d days", subId, countDays),
Title: "Interest Following Extension",
Description: fmt.Sprintf("Interest %s: extend following by %d days", subId, countDays),
Payload: string(orderData),
Currency: eh.CfgPayment.Currency.Code,
Prices: []telebot.Price{
Expand Down Expand Up @@ -146,12 +146,12 @@ func (eh ExtendHandler) ExtendPaid(tgCtx telebot.Context, args ...string) (err e
err = backoff.RetryNotify(e.runOnce, b, func(err error, d time.Duration) {
eh.Log.Warn(fmt.Sprintf(msgFmtRunOnceFailed, op.SubId, userId, err, d))
if d > 1*time.Second {
_ = tgCtx.Send("Extending the subscription, please wait...")
_ = tgCtx.Send("Extending the interest following, please wait...")
}
})
}
if err == nil {
err = tgCtx.Send(fmt.Sprintf("Subscription has been successfully extended by %d days", op.DaysAdd))
err = tgCtx.Send(fmt.Sprintf("Interest following has been successfully extended by %d days", op.DaysAdd))
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions service/subscriptions/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ListOnGroupStartHandlerFunc(clientAwk api.Client, svcReader reader.Service,
m, err = listButtons(groupIdCtx, userId, clientAwk, svcReader, tgCtx.Chat().ID, CmdStart, "")
if err == nil {
err = tgCtx.Send(
"Own subscriptions list. "+
"Own interests list. "+
"Use the <a href=\"https://awakari.com/login.html\" target=\"_blank\">app</a> to manage. "+
"Select one or more to read in this chat:",
m, telebot.ModeHTML,
Expand All @@ -42,7 +42,7 @@ func PageNext(clientAwk api.Client, svcReader reader.Service, groupId string) se
var m *telebot.ReplyMarkup
m, err = listButtons(groupIdCtx, userId, clientAwk, svcReader, tgCtx.Chat().ID, args[0], cursor)
if err == nil {
err = tgCtx.Send("Own subscriptions list page:", m, telebot.ModeHTML)
err = tgCtx.Send("Own interests list page:", m, telebot.ModeHTML)
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions service/subscriptions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
)

const CmdStart = "sub_start"
const MsgFmtChatLinked = "Linked the subscription \"%s\" to this chat. " +
const MsgFmtChatLinked = "Following the interest \"%s\" in this chat. " +
"New results will appear here. " +
"To manage own subscriptions use the <a href=\"https://awakari.com/login.html\" target=\"blank\">app</a>."
"To manage own interests use the <a href=\"https://awakari.com/login.html\" target=\"blank\">app</a>."

func Start(
clientAwk api.Client,
Expand Down
2 changes: 1 addition & 1 deletion service/subscriptions/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Stop(svcReader reader.Service) service.ArgHandlerFunc {
err = svcReader.DeleteCallback(ctx, subId, cb.Url)
}
if err == nil {
_ = tgCtx.Send("Unlinked the subscription from this chat")
_ = tgCtx.Send("Stopped following the interest in this chat")
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions service/usage/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (lh LimitsHandler) RequestExtension(tgCtx telebot.Context, args ...string)
//case usage.SubjectSubscriptions:
// err = tgCtx.Send(
// fmt.Sprintf(
// "The limit extension price is %s %.2f per day per subscription starting from 2nd. "+
// "The limit extension price is %s %.2f per day per interest starting from 2nd. "+
// "Reply with the count of days to add:",
// lh.CfgPayment.Currency.Code,
// lh.CfgPayment.Price.Subscription.CountLimit,
Expand Down Expand Up @@ -220,7 +220,7 @@ func formatUsageSubject(subj usage.Subject) (s string) {
case usage.SubjectPublishEvents:
s = "Message Daily Publications"
case usage.SubjectSubscriptions:
s = "Subscriptions Count"
s = "Interests Count"
default:
s = "undefined"
}
Expand Down

0 comments on commit 226bb21

Please sign in to comment.