profile

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExistingSocialLink = errors.New("existing social link")
View Source
var ErrInvalidDisplayName = errors.New("invalid display name")
View Source
var ErrNotFound = errors.New("not found")

Functions

func NewChatProfileReader added in v1.16.0

func NewChatProfileReader(store Store, media Media) chat.ProfileReader

NewChatProfileReader returns a chat.ProfileReader backed by the given profile store and blob storage, for wiring the Chat service. The media dependency is what lets member avatars come back with resolved blob metadata, so chat itself never touches blob storage.

Types

type Media added in v1.22.0

type Media interface {
	// SetAsProfilePicture validates that ownerID owns the blob and that it can back
	// a picture, then grants ownerID's public profile read access to it. It returns
	// one of blob.ErrBlobNotFound, blob.ErrBlobNotReady, blob.ErrBlobRejected, or
	// blob.ErrBlobInvalid when the blob cannot be used.
	SetAsProfilePicture(ctx context.Context, ownerID *commonpb.UserId, blobID *blobpb.BlobId) error

	// ResolveRenditions returns each original's full rendition set — the ORIGINAL
	// plus every derived rendition, each with a freshly minted, short-lived download
	// URL — keyed by string(BlobId.Value). It performs no authorization.
	ResolveRenditions(ctx context.Context, ids []*blobpb.BlobId) (map[string][]*blobpb.Rendition, error)
}

Media is the blob storage surface the profile service depends on, satisfied by blob.Integration. It is declared here, rather than depending on the blob server directly, so the dependency runs one way: profile states what it needs of blob storage and the wiring supplies it.

type PhoneForPayment added in v1.14.0

type PhoneForPayment struct {
	PhoneNumber *phonepb.PhoneNumber
	UserID      *commonpb.UserId
	JoinedAt    time.Time
}

PhoneForPayment is a payment-enabled phone number together with the user that owns it.

type Server

type Server struct {
	profilepb.UnimplementedProfileServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(log *zap.Logger, authz auth.Authorizer, accounts account.Store, profiles Store, media Media, moderator moderation.Client, xClient *x.Client) *Server

func (*Server) GetProfile

func (*Server) SetProfilePicture added in v1.22.0

type Store

type Store interface {
	// GetProfile returns the user profile for a user, or ErrNotFound.
	GetProfile(ctx context.Context, id *commonpb.UserId, includePrivateProfile bool) (*profilepb.UserProfile, error)

	// SetDisplayName sets the display name for a user, provided they exist.
	//
	// ErrInvalidDisplayName is returned if there is an issue with the display name.
	SetDisplayName(ctx context.Context, id *commonpb.UserId, displayName string) error

	// GetDisplayNames returns, for each of the given users that has a display
	// name set, that display name keyed by string(userID.Value). Users without
	// one are absent from the map. It resolves the whole set in a single lookup.
	GetDisplayNames(ctx context.Context, userIDs []*commonpb.UserId) (map[string]string, error)

	// SetProfilePicture sets the user's profile picture to the blob holding its
	// ORIGINAL rendition, replacing any picture already set.
	SetProfilePicture(ctx context.Context, id *commonpb.UserId, blobID *blobpb.BlobId) error

	// GetProfilePictures returns, for each of the given users that has a profile
	// picture set, the blob holding its ORIGINAL rendition keyed by
	// string(userID.Value). Users without one are absent from the map. It resolves
	// the whole set in a single lookup.
	GetProfilePictures(ctx context.Context, userIDs []*commonpb.UserId) (map[string]*blobpb.BlobId, error)

	// LinkPhoneNumber links the phone number and its precomputed hash to a user, provided
	// they exist. Any other user previously holding the same phone number has both fields
	// cleared.
	LinkPhoneNumber(ctx context.Context, id *commonpb.UserId, phoneNumber string, phoneNumberHash *commonpb.Hash) error

	// UnlinkPhoneNumber removes the link for the phone number
	UnlinkPhoneNumber(ctx context.Context, userID *commonpb.UserId, phoneNumber string) error

	// LinkPhoneNumberForPayment marks the user's linked phone number as enabled for
	// payment, provided the given phone number is currently linked to the user. It
	// reports whether the flag transitioned from false to true (false if it was
	// already enabled).
	//
	// ErrNotFound is returned when the phone number is not associated with the user.
	LinkPhoneNumberForPayment(ctx context.Context, userID *commonpb.UserId, phoneNumber string) (bool, error)

	// IsPhoneNumberLinkedForPayment reports whether the given phone number is
	// currently linked to the user and enabled for payment.
	IsPhoneNumberLinkedForPayment(ctx context.Context, userID *commonpb.UserId, phoneNumber string) (bool, error)

	// GetPhonesByHashes returns the phone numbers for users whose stored
	// phoneNumberHash matches any of the provided hashes. Order is unspecified.
	GetPhonesByHashes(ctx context.Context, hashes []*commonpb.Hash) ([]*phonepb.PhoneNumber, error)

	// GetPhonesByHashesForPayment returns the payment-enabled phone numbers,
	// each paired with the user that owns it, for users whose stored
	// phoneNumberHash matches any of the provided hashes and who have enabled
	// their phone number for payment. Order is unspecified.
	GetPhonesByHashesForPayment(ctx context.Context, hashes []*commonpb.Hash) ([]*PhoneForPayment, error)

	// GetPhoneNumbersForPayment returns, for each of the given users that has a
	// phone number enabled for payment, that phone number keyed by
	// string(userID.Value). Users without a payment-enabled phone number are
	// absent from the map. It resolves the whole set in a single lookup.
	GetPhoneNumbersForPayment(ctx context.Context, userIDs []*commonpb.UserId) (map[string]*phonepb.PhoneNumber, error)

	// GetUserIdByPhoneNumber returns the UserId currently linked to the given
	// phone number. Returns ErrNotFound when no user holds the number.
	GetUserIdByPhoneNumber(ctx context.Context, phoneNumber string) (*commonpb.UserId, error)

	// GetUserIdByPhoneNumberForPayment returns the UserId currently linked to the
	// given phone number, but only when that user has enabled the phone number for
	// payment. Returns ErrNotFound when no user holds the number or the number is
	// not enabled for payment.
	GetUserIdByPhoneNumberForPayment(ctx context.Context, phoneNumber string) (*commonpb.UserId, error)

	// LinkEmailAddress links the email address to a user, provided they exist. Any other
	// user previously holding the same email address has it cleared.
	LinkEmailAddress(ctx context.Context, id *commonpb.UserId, emailAddress string) error

	// UnlinkPhoneNumber removes the link for the email address
	UnlinkEmailAddress(ctx context.Context, userID *commonpb.UserId, emailAddress string) error

	// LinkXAccount links a X account to a user ID
	LinkXAccount(ctx context.Context, userID *commonpb.UserId, xProfile *profilepb.XProfile, accessToken string) error

	// UnlinkXAccount removes the link to the X account
	UnlinkXAccount(ctx context.Context, userID *commonpb.UserId, xUserID string) error

	// GetXProfile gets a user's X profile if it has been linked
	GetXProfile(ctx context.Context, userID *commonpb.UserId) (*profilepb.XProfile, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL